@@ -538,7 +538,6 @@ def __init__(
538
538
shutdown_timer: Number of seconds to shut down websocket connection after last use
539
539
"""
540
540
# TODO allow setting max concurrent connections and rpc subscriptions per connection
541
- # TODO reconnection logic
542
541
self .ws_url = ws_url
543
542
self .ws : Optional [ClientConnection ] = None
544
543
self .max_subscriptions = asyncio .Semaphore (max_subscriptions )
@@ -551,7 +550,6 @@ def __init__(
551
550
self ._send_recv_task = None
552
551
self ._inflight : dict [str , str ] = {}
553
552
self ._attempts = 0
554
- self ._initialized = False # TODO remove
555
553
self ._lock = asyncio .Lock ()
556
554
self ._exit_task = None
557
555
self ._options = options if options else {}
@@ -612,19 +610,17 @@ async def connect(self, force=False):
612
610
if self ._exit_task :
613
611
self ._exit_task .cancel ()
614
612
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 )
622
623
)
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
628
624
629
625
async def _handler (self , ws : ClientConnection ) -> None :
630
626
recv_task = asyncio .create_task (self ._start_receiving (ws ))
@@ -681,7 +677,6 @@ async def shutdown(self):
681
677
except asyncio .TimeoutError :
682
678
pass
683
679
self .ws = None
684
- self ._initialized = False
685
680
self ._send_recv_task = None
686
681
687
682
async def _recv (self , recd : bytes ) -> None :
@@ -2344,8 +2339,6 @@ async def _make_rpc_request(
2344
2339
force_legacy_decode : bool = False ,
2345
2340
) -> RequestManager .RequestResults :
2346
2341
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?
2349
2342
2350
2343
subscription_added = False
2351
2344
0 commit comments