You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use gevent patch for my program, but in the program, I need to execute asyncio related code in sub threads
When multiple sub threads execute the same coroutine, it triggers "RuntimeError: This event loop is already running"
They are different threads, I generated its own event loop for each sub thread,I cannot understand this issue
When I commented out the monkey patch, the program executed as I expected
ERROR:root:This event loop is already running
Traceback (most recent call last):
File "/Users/computer1/pytest/test.py", line 30, in func1
loop.run_until_complete(asyncf1())
File "/opt/homebrew/Cellar/[email protected]/3.9.18_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 623, in run_until_completeself._check_running()
File "/opt/homebrew/Cellar/[email protected]/3.9.18_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 583, in _check_runningraiseRuntimeError('This event loop is already running')
RuntimeError: This event loop is already running
/Users/computer1/pytest/test.py:32: RuntimeWarning: coroutine 'asyncf1' was never awaited
logging.error(e, exc_info=True)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
ERROR:root:This event loop is already running
Traceback (most recent call last):
File "/Users/computer1/pytest/test.py", line 30, in func1
loop.run_until_complete(asyncf1())
File "/opt/homebrew/Cellar/[email protected]/3.9.18_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 623, in run_until_completeself._check_running()
File "/opt/homebrew/Cellar/[email protected]/3.9.18_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 583, in _check_runningraiseRuntimeError('This event loop is already running')
RuntimeError: This event loop is already running
Description:
I use gevent patch for my program, but in the program, I need to execute asyncio related code in sub threads
When multiple sub threads execute the same coroutine, it triggers "RuntimeError: This event loop is already running"
They are different threads, I generated its own event loop for each sub thread,I cannot understand this issue
When I commented out the monkey patch, the program executed as I expected
What I've run:
The text was updated successfully, but these errors were encountered: