@@ -530,7 +530,7 @@ def stream(self, print_to_console: bool = True) -> None:
530530 self .print_to_console = print_to_console
531531
532532 # Connect to the Websocket.
533- self .loop .run_until_complete (self ._connect (pipeline_start = False ))
533+ self .loop .run_until_complete (self ._connect ())
534534
535535 # Send the Request.
536536 asyncio .ensure_future (self ._send_message (self ._build_data_request ()))
@@ -597,7 +597,7 @@ async def close_stream(self) -> None:
597597 # except asyncio.CancelledError:
598598 # print("main(): cancel_me is cancelled now")
599599
600- async def _connect (self , pipeline_start : bool = True ) -> websockets .WebSocketClientProtocol :
600+ async def _connect (self ) -> websockets .WebSocketClientProtocol :
601601 """Connects the Client to the TD Websocket.
602602
603603 Connecting to webSocket server websockets.client.connect
@@ -621,21 +621,13 @@ async def _connect(self, pipeline_start: bool = True) -> websockets.WebSocketCli
621621 # Create a connection.
622622 self .connection = await websockets .client .connect (self .websocket_url )
623623
624- # check it before sending it back .
625- if await self ._check_connection () and pipeline_start == True :
624+ # See if we are connected .
625+ is_connected = await self ._check_connection ()
626626
627- # Login to the stream.
627+ # If we are connected then login.
628+ if is_connected :
628629 await self ._send_message (login_request )
629- await self ._receive_message (return_value = True )
630630 return self .connection
631-
632- else :
633-
634- # Login to the stream.
635- await self ._send_message (login_request )
636- await self ._receive_message (return_value = False )
637- return self .connection
638-
639631
640632 async def _check_connection (self ) -> bool :
641633 """Determines if we have an active connection
@@ -717,7 +709,7 @@ async def _receive_message(self, return_value: bool = False) -> dict:
717709 print ('' )
718710 print (message_decoded )
719711 print ('-' * 20 )
720- print ('' )
712+ print ('' )
721713
722714 except websockets .exceptions .ConnectionClosed :
723715
0 commit comments