24 lines
678 B
Python
24 lines
678 B
Python
import asyncio
|
|
import traceback
|
|
|
|
|
|
def task_done_callback(future: asyncio.Future):
|
|
"""Print out debug information for background tasks."""
|
|
try:
|
|
if future.result() is not None:
|
|
print(f"{future.get_name()} result {future.result}")
|
|
|
|
except asyncio.CancelledError:
|
|
print(f"{future.get_name()} was cancelled")
|
|
|
|
except Exception as exception:
|
|
formatted = traceback.format_exception(
|
|
type(exception),
|
|
exception,
|
|
exception.__traceback__,
|
|
)
|
|
for chunk in formatted:
|
|
line = chunk.splitlines()
|
|
for line in chunk.splitlines():
|
|
print(line.rstrip())
|