mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-19 16:03:00 +00:00
Use variable instead of monkey patching asyncio
This commit is contained in:
@@ -31,10 +31,11 @@ from tornado.platform.asyncio import to_asyncio_future
|
||||
# For compatibility with python versions 3.6 or earlier.
|
||||
# asyncio.Task.all_tasks() is fully moved to asyncio.all_tasks() starting with 3.9. Also applies to current_task.
|
||||
try:
|
||||
asyncio.all_tasks
|
||||
asyncio_all_tasks = asyncio.all_tasks
|
||||
asyncio_current_task = asyncio.current_task
|
||||
except AttributeError as e:
|
||||
asyncio.all_tasks = asyncio.Task.all_tasks
|
||||
asyncio.current_task = asyncio.Task.current_task
|
||||
asyncio_all_tasks = asyncio.Task.all_tasks
|
||||
asyncio_current_task = asyncio.Task.current_task
|
||||
|
||||
|
||||
def random_port():
|
||||
@@ -482,7 +483,7 @@ def print_stacks(file=sys.stderr):
|
||||
# also show asyncio tasks, if any
|
||||
# this will increase over time as we transition from tornado
|
||||
# coroutines to native `async def`
|
||||
tasks = asyncio.all_tasks()
|
||||
tasks = asyncio_all_tasks()
|
||||
if tasks:
|
||||
print("AsyncIO tasks: %i" % len(tasks))
|
||||
for task in tasks:
|
||||
|
Reference in New Issue
Block a user