Fix "DeprecationWarning: There is no current event loop" (#2390)

Co-authored-by: Adam Hopkins <adam@amhopkins.com>
This commit is contained in:
Javier Marcet 2022-03-30 08:40:30 +02:00 committed by GitHub
parent 0cb342aef4
commit bb4474897f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,7 @@ from asyncio import (
CancelledError,
Task,
ensure_future,
get_event_loop,
get_event_loop_policy,
get_running_loop,
wait_for,
)
@ -253,7 +253,7 @@ class Sanic(BaseSanic, RunnerMixin, metaclass=TouchUpMeta):
"Loop can only be retrieved after the app has started "
"running. Not supported with `create_server` function"
)
return get_event_loop()
return get_event_loop_policy().get_event_loop()
# -------------------------------------------------------------------- #
# Registration