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:
Min RK
2018-03-01 14:39:03 +01:00
parent a184d372f4
commit 773973825f

View File

@@ -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)