Skip to content

Commit 5ca422b

Browse files
committed
Create a future result before sending its request
1 parent 2dca5ae commit 5ca422b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

pyrogram/session/session.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ async def send(self, data: TLObject, wait_response: bool = True, timeout: float
282282
message = self.msg_factory(data)
283283
msg_id = message.msg_id
284284

285+
if wait_response:
286+
self.results[msg_id] = Result()
287+
285288
log.debug("Sent: %s", message)
286289

287290
payload = await self.loop.run_in_executor(
@@ -297,8 +300,6 @@ async def send(self, data: TLObject, wait_response: bool = True, timeout: float
297300
await self.connection.send(payload)
298301

299302
if wait_response:
300-
self.results[msg_id] = Result()
301-
302303
try:
303304
await asyncio.wait_for(self.results[msg_id].event.wait(), timeout)
304305
except asyncio.TimeoutError:

0 commit comments

Comments
 (0)