mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-11-11 03:20:35 +00:00
Fix event loop not being passed into many asyncio calls
This commit is contained in:
@@ -43,5 +43,5 @@ class MessageContainer(TLObject):
|
||||
before = reader.tell_position()
|
||||
obj = reader.tgread_object() # May over-read e.g. RpcResult
|
||||
reader.set_position(before + length)
|
||||
messages.append(TLMessage(msg_id, seq_no, obj))
|
||||
messages.append(TLMessage(msg_id, seq_no, obj, loop=None))
|
||||
return MessageContainer(messages)
|
||||
|
||||
@@ -24,10 +24,13 @@ class TLMessage(TLObject):
|
||||
sent `TLMessage`, and this result can be represented as a `Future`
|
||||
that will eventually be set with either a result, error or cancelled.
|
||||
"""
|
||||
def __init__(self, msg_id, seq_no, obj, out=False, after_id=0):
|
||||
def __init__(self, msg_id, seq_no, obj, *, loop, out=False, after_id=0):
|
||||
self.obj = obj
|
||||
self.container_msg_id = None
|
||||
self.future = asyncio.Future()
|
||||
|
||||
# If no loop is given then it is an incoming message.
|
||||
# Only outgoing messages need the future to await them.
|
||||
self.future = asyncio.Future(loop=loop) if loop else None
|
||||
|
||||
# After which message ID this one should run. We do this so
|
||||
# InvokeAfterMsgRequest is transparent to the user and we can
|
||||
|
||||
@@ -181,7 +181,7 @@ class Conversation(ChatGetter):
|
||||
return incoming
|
||||
|
||||
# Otherwise the next incoming response will be the one to use
|
||||
future = asyncio.Future()
|
||||
future = asyncio.Future(loop=self._client.loop)
|
||||
pending[target_id] = future
|
||||
return self._get_result(future, start_time, timeout)
|
||||
|
||||
@@ -209,7 +209,7 @@ class Conversation(ChatGetter):
|
||||
return earliest_edit
|
||||
|
||||
# Otherwise the next incoming response will be the one to use
|
||||
future = asyncio.Future()
|
||||
future = asyncio.Future(loop=self._client.loop)
|
||||
self._pending_edits[target_id] = future
|
||||
return await self._get_result(future, start_time, timeout)
|
||||
|
||||
@@ -220,7 +220,7 @@ class Conversation(ChatGetter):
|
||||
will also trigger even without a response.
|
||||
"""
|
||||
start_time = time.time()
|
||||
future = asyncio.Future()
|
||||
future = asyncio.Future(loop=self._client.loop)
|
||||
target_id = self._get_message_id(message)
|
||||
|
||||
if self._last_read is None:
|
||||
@@ -265,7 +265,7 @@ class Conversation(ChatGetter):
|
||||
counter = Conversation._custom_counter
|
||||
Conversation._custom_counter += 1
|
||||
|
||||
future = asyncio.Future()
|
||||
future = asyncio.Future(loop=self._client.loop)
|
||||
async def result():
|
||||
try:
|
||||
return await self._get_result(future, start_time, timeout)
|
||||
|
||||
Reference in New Issue
Block a user