Skip to content

Commit f651aa0

Browse files
authored
Merge pull request #110 from robertsmd/master
fix race condition on login. awaits login response
2 parents d0c611f + e7aee60 commit f651aa0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

td/stream.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,12 @@ async def _connect(self) -> websockets.WebSocketClientProtocol:
636636
# If we are connected then login.
637637
if is_connected:
638638
await self._send_message(login_request)
639-
return self.connection
639+
while True:
640+
response = await self._receive_message(return_value=True)
641+
responses = response.get('response')
642+
for r in responses:
643+
if r.get('service') == 'ADMIN' and r.get('command') == 'LOGIN':
644+
return self.connection
640645

641646
async def _check_connection(self) -> bool:
642647
"""Determines if we have an active connection

0 commit comments

Comments
 (0)