Skip to main content

All Questions

0 votes
0 answers
208 views

How to prioritize the tasks of asyncio eventloop?

I want to create a custom implementation of the asyncio eventloop so that the tasks handled by the eventloop have a priority. The tasks that are available or "ready" can then be ordered by ...
Pablo Martínez Aragón's user avatar
4 votes
1 answer
9k views

"RuntimeError: no running event loop" with "asyncio.get_running_loop()" in Python

I'm trying to run the code below with asyncio.get_running_loop(): import asyncio async def test(): for _ in range(3): print("Test") await asyncio.sleep(1) loop = ...
Super Kai - Kazuya Ito's user avatar
0 votes
1 answer
647 views

"RuntimeError: Cannot close a running event loop" in Python

I use loop.close() in test() to close the event loop as shown below: import asyncio async def test(loop): print("Test") loop.stop() # Stop the event loop loop.close() # Here ...
Super Kai - Kazuya Ito's user avatar
0 votes
1 answer
3k views

How to stop "loop.run_forever()" with "loop.stop()" in Python?

I'm trying to stop loop.run_forever() with loop.stop() in Python as shown below but loop.stop() doesn't stop loop.run_forever(): import asyncio async def test(): print("Test") loop = ...
Super Kai - Kazuya Ito's user avatar
2 votes
1 answer
3k views

How to add a task to event loop while it is already running in asyncio library in python3.7?

# !/usr/bin/python3 import asyncio import aiohttp from threading import Thread event_loop = asyncio.get_event_loop() # getting the event_loop Thread(target=event_loop.run_forever).start() # creating ...
JustieK's user avatar
  • 21
7 votes
4 answers
8k views

asyncio task was destroyed but it is pending

I am working a sample program that reads from a datasource (csv or rdbms) in chunks, makes some transformation and sends it via socket to a server. But because the csv is very large, for testing ...
spyder's user avatar
  • 155
9 votes
1 answer
6k views

How to reset an asyncio eventloop by a worker?

I'm working with an asyncio forever() eventloop. Now I want to restart the loop (stop the loop and recreate a new loop) after a process or a signal or a change in a file, but I have some problems to ...
Benyamin Jafari's user avatar
2 votes
1 answer
3k views

How python asyncIO, suspend & resume the task?

A style of programming in which task release the CPU during waiting periods, so that other tasks can use it. To introduce an async task, A task should be capable to suspend & resume An event ...
overexchange's user avatar
7 votes
2 answers
17k views

Two independent async loops in Python

What would be a good approach to execute two asynchronous loops running in parallel in Python, using async/await? I've thought about something like the code below, but can't wrap my head around how ...
Jivan's user avatar
  • 23.1k