nest_ayncio breaks tests under Python 3.10.9
tammyalexandra opened this issue · 2 comments
tammyalexandra commented
I'm using nest_asyncio.apply()
at the top of one of my automated test files. When I run poetry run pytest tests/conftest.py
(Poetry 1.3.2, Python 3.10.9 (just upgraded from 3.10.7):
ImportError while loading conftest 'tests/conftest.py'.
tests/conftest.py:13: in <module>
nest_asyncio.apply()
../Library/Caches/pypoetry/virtualenvs/xxx-08n5XoMP-py3.10/lib/python3.10/site-packages/nest_asyncio.py:16: in apply
loop = loop or asyncio.get_event_loop()
../Library/Caches/pypoetry/virtualenvs/xxx-08n5XoMP-py3.10/lib/python3.10/site-packages/nest_asyncio.py:45: in _get_event_loop
loop = events.get_event_loop_policy().get_event_loop()
/usr/local/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/events.py:666: in get_event_loop
warnings.warn('There is no current event loop',
E DeprecationWarning: There is no current event loop
I was able to patch it temporarily like so:
import asyncio
loop = asyncio.get_event_loop_policy().new_event_loop()
nest_asyncio.apply(loop)
But it would be better for this package to make the necessary changes internally.
Thank you!
SeriousSamV commented
why is this issue still open?
erdewit commented
This is fixed in v1.5.7