mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-11-12 12:00:37 +00:00
Stop using asyncio.get_event_loop()
It is deprecated in newer Python versions. Closes #4013.
This commit is contained in:
@@ -2088,7 +2088,7 @@ the scenes! This means you're now able to do both of the following:
|
||||
async def main():
|
||||
await client.send_message('me', 'Hello!')
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(main())
|
||||
asyncio.run(main())
|
||||
|
||||
# ...can be rewritten as:
|
||||
|
||||
|
||||
@@ -161,19 +161,17 @@ just get rid of ``telethon.sync`` and work inside an ``async def``:
|
||||
|
||||
await client.run_until_disconnected()
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
asyncio.run(main())
|
||||
|
||||
|
||||
The ``telethon.sync`` magic module simply wraps every method behind:
|
||||
The ``telethon.sync`` magic module essentially wraps every method behind:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
asyncio.run(main())
|
||||
|
||||
So that you don't have to write it yourself every time. That's the
|
||||
overhead you pay if you import it, and what you save if you don't.
|
||||
With some other tricks, so that you don't have to write it yourself every time.
|
||||
That's the overhead you pay if you import it, and what you save if you don't.
|
||||
|
||||
Learning
|
||||
========
|
||||
|
||||
Reference in New Issue
Block a user