@@ -538,7 +538,6 @@ def __init__(
538538 shutdown_timer: Number of seconds to shut down websocket connection after last use
539539 """
540540 # TODO allow setting max concurrent connections and rpc subscriptions per connection
541- # TODO reconnection logic
542541 self .ws_url = ws_url
543542 self .ws : Optional [ClientConnection ] = None
544543 self .max_subscriptions = asyncio .Semaphore (max_subscriptions )
@@ -551,7 +550,6 @@ def __init__(
551550 self ._send_recv_task = None
552551 self ._inflight : dict [str , str ] = {}
553552 self ._attempts = 0
554- self ._initialized = False # TODO remove
555553 self ._lock = asyncio .Lock ()
556554 self ._exit_task = None
557555 self ._options = options if options else {}
@@ -612,19 +610,17 @@ async def connect(self, force=False):
612610 if self ._exit_task :
613611 self ._exit_task .cancel ()
614612 if self .state not in (State .OPEN , State .CONNECTING ) or force :
615- if not self ._initialized or force :
616- try :
617- await asyncio .wait_for (self ._cancel (), timeout = 10.0 )
618- except asyncio .TimeoutError :
619- pass
620- self .ws = await asyncio .wait_for (
621- connect (self .ws_url , ** self ._options ), timeout = 10.0
613+ try :
614+ await asyncio .wait_for (self ._cancel (), timeout = 10.0 )
615+ except asyncio .TimeoutError :
616+ pass
617+ self .ws = await asyncio .wait_for (
618+ connect (self .ws_url , ** self ._options ), timeout = 10.0
619+ )
620+ if self ._send_recv_task is None or self ._send_recv_task .done ():
621+ self ._send_recv_task = asyncio .get_running_loop ().create_task (
622+ self ._handler (self .ws )
622623 )
623- if self ._send_recv_task is None or self ._send_recv_task .done ():
624- self ._send_recv_task = asyncio .get_running_loop ().create_task (
625- self ._handler (self .ws )
626- )
627- self ._initialized = True
628624
629625 async def _handler (self , ws : ClientConnection ) -> None :
630626 recv_task = asyncio .create_task (self ._start_receiving (ws ))
@@ -681,7 +677,6 @@ async def shutdown(self):
681677 except asyncio .TimeoutError :
682678 pass
683679 self .ws = None
684- self ._initialized = False
685680 self ._send_recv_task = None
686681
687682 async def _recv (self , recd : bytes ) -> None :
@@ -2344,8 +2339,6 @@ async def _make_rpc_request(
23442339 force_legacy_decode : bool = False ,
23452340 ) -> RequestManager .RequestResults :
23462341 request_manager = RequestManager (payloads )
2347- # TODO maybe instead of the current logic, I should assign the futs during send() and then just
2348- # TODO use that to determine when it's completed. But how would this work with subscriptions?
23492342
23502343 subscription_added = False
23512344
0 commit comments