Skip to content

Commit

Permalink
Merge pull request #110 from robertsmd/master
Browse files Browse the repository at this point in the history
fix race condition on login. awaits login response
  • Loading branch information
areed1192 authored Oct 2, 2020
2 parents d0c611f + e7aee60 commit f651aa0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion td/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,12 @@ async def _connect(self) -> websockets.WebSocketClientProtocol:
# If we are connected then login.
if is_connected:
await self._send_message(login_request)
return self.connection
while True:
response = await self._receive_message(return_value=True)
responses = response.get('response')
for r in responses:
if r.get('service') == 'ADMIN' and r.get('command') == 'LOGIN':
return self.connection

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

0 comments on commit f651aa0

Please sign in to comment.