-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
type: refactorCleanup or refactoring tasks that don't add functionality or fix bugsCleanup or refactoring tasks that don't add functionality or fix bugs
Description
The use of asyncio.get_event_loop
causes a DeprecationWarning
for Python 3.10, and will become an error in some future version of Python.
Here's the output of the test run on my machine on Python 3.10:
(traits-futures) mdickinson@mirzakhani traits-futures % python -m unittest
/Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
................ssssssssssssssss............................................................/Users/mdickinson/.venvs/traits-futures/lib/python3.10/site-packages/pyface/base_toolkit.py:285: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
plugin for plugin in importlib_metadata.entry_points()[entry_point]
../Users/mdickinson/.venvs/traits-futures/lib/python3.10/site-packages/pyface/base_toolkit.py:216: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
entry_point_group = importlib_metadata.entry_points()[entry_point]
....ss................................................................................................/Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
../Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
./Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
............/Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
..................../Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
../Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
./Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
..................../Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
../Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
./Users/mdickinson/Enthought/Projects/traits-futures/traits_futures/asyncio/event_loop.py:28: DeprecationWarning: There is no current event loop
self._event_loop = asyncio.get_event_loop()
...........ssssssssssssssss
----------------------------------------------------------------------
Ran 284 tests in 19.763s
OK (skipped=34)
The easiest quick fix is to replace uses of asyncio.get_event_loop
with asyncio.new_event_loop
. The catch is that that leaves us responsible for clearing up (i.e., explicitly closing) those event loops, to avoid getting ResourceWarning
warnings.
See https://bugs.python.org/issue39529 for the rationale for the deprecation, and related discussion.
Metadata
Metadata
Assignees
Labels
type: refactorCleanup or refactoring tasks that don't add functionality or fix bugsCleanup or refactoring tasks that don't add functionality or fix bugs