0

python3.10-asyncio-get_event_loop

Deprecated since version 3.10: Emits a deprecation warning if there is no running event loop. In future Python releases, this function may become an alias of get_running_loop() and will accordingly raise a RuntimeError if there is no running event loop.

The behavior of get_event_loop has changed in version 3.10, now the sanic-jwt library needs to be compatible with later versions of 3.10, and needs to be modified to remove this warning(DeprecationWarning: There is no current event loop)

The place of the warning is the call method under ConfigItem on line 134 sanic_jwt/configuration.py

enter image description here

I tried the method of this article and the test did not pass. It should not match the behavior of the version before 3.10

PR

iAsuka
  • 1
  • I need a function for py3.10 get_event_loop that behaves the same way as get_event_loop before 3.10 – iAsuka Dec 04 '22 at 09:55

1 Answers1

0

If you want to patch the library, you could replace line 134:

if asyncio.get_event_loop().is_running():
    # some code

with:

try:
    asyncio.get_running_loop()
except RuntimeError:
    pass
else:
    # some code

That should work with all versions of Python.

Paul Cornelius
  • 9,245
  • 1
  • 15
  • 24