mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-19 16:03:00 +00:00
also show asyncio task stacks
which are nicely formatted on their own there won't be many yet, but if we transition to async def, we will get lots more useful info
This commit is contained in:
@@ -375,6 +375,7 @@ def print_stacks(file=sys.stderr):
|
||||
"""
|
||||
# local imports because these will not be used often,
|
||||
# no need to add them to startup
|
||||
import asyncio
|
||||
import resource
|
||||
import traceback
|
||||
from .log import coroutine_frames
|
||||
@@ -403,3 +404,12 @@ def print_stacks(file=sys.stderr):
|
||||
|
||||
print(''.join(['\n'] + traceback.format_list(stack)), file=file)
|
||||
|
||||
# also show asyncio tasks, if any
|
||||
# this will increase over time as we transition from tornado
|
||||
# coroutines to native `async def`
|
||||
tasks = asyncio.Task.all_tasks()
|
||||
if tasks:
|
||||
print("AsyncIO tasks: %i" % len(tasks))
|
||||
for task in tasks:
|
||||
task.print_stack(file=file)
|
||||
|
||||
|
Reference in New Issue
Block a user