Hi
30.03.2022 21:44, Larry Martell пишет:
On Wed, Mar 30, 2022 at 2:40 PM Kirill Ratkin via Python-list
wrote:
Hi again,
I changed a bit your example and it works as you expected I hope.
import asyncio
async def long():
for i in range(100):
await asyncio.sleep(10)
On Wed, Mar 30, 2022 at 2:40 PM Kirill Ratkin via Python-list
wrote:
>
> Hi again,
>
> I changed a bit your example and it works as you expected I hope.
>
> import asyncio
>
>
> async def long():
> for i in range(100):
> await asyncio.sleep(10)
> print("long is done")
>
>
>
Hi again,
I changed a bit your example and it works as you expected I hope.
import asyncio
async def long():
for i in range(100):
await asyncio.sleep(10)
print("long is done")
loop = asyncio.get_event_loop()
task = loop.create_task(long())
print('after asyncio.run')
loop
Hi,
You can use asyncio.create_task and gather results. See docs -
https://docs.python.org/3/library/asyncio-task.html
But think twice what you want to do in async task. Do you use synchronous
requests to database? If yes it will blocks eventloop...
If you use Django it makes sense to use someth