mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Avoid explicitly passing the loop to asyncio
This behaviour is deprecated and will be removed in future versions of Python. Technically, it could be considered a bug (invalid usage causing different behaviour from the expected one), and in practice it should not break much code (because .get_event_loop() would likely be the same event loop anyway).
This commit is contained in:
@@ -206,10 +206,9 @@ class InlineQuery(EventBuilder):
|
||||
return
|
||||
|
||||
if results:
|
||||
futures = [self._as_future(x, self._client.loop)
|
||||
for x in results]
|
||||
futures = [self._as_future(x) for x in results]
|
||||
|
||||
await asyncio.wait(futures, loop=self._client.loop)
|
||||
await asyncio.wait(futures)
|
||||
|
||||
# All futures will be in the `done` *set* that `wait` returns.
|
||||
#
|
||||
@@ -236,10 +235,10 @@ class InlineQuery(EventBuilder):
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _as_future(obj, loop):
|
||||
def _as_future(obj):
|
||||
if inspect.isawaitable(obj):
|
||||
return asyncio.ensure_future(obj, loop=loop)
|
||||
return asyncio.ensure_future(obj)
|
||||
|
||||
f = loop.create_future()
|
||||
f = asyncio.get_event_loop().create_future()
|
||||
f.set_result(obj)
|
||||
return f
|
||||
|
Reference in New Issue
Block a user