Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug and list all coroutine pending by future in python asyncio

I have a production code that heavily used asyncio.semaphore module which is suspected to have deadlock problem. I already found some solution of how to attach to running python code with unix signal, debug with ipdb.set_trace() and list all tasks on event loop with asyncio.Task.all_tasks(). Can I further inspect into the stack frame of each task or viewing each line of coroutine which is currently pending by futures on ipdb?

like image 575
RainJay Avatar asked Aug 02 '17 04:08

RainJay


1 Answers

As OP observes, further inspections may be obtained with

[*map(asyncio.Task.print_stack, asyncio.Task.all_tasks())]

(OP is certainly free to self-answer.)

like image 152
J_H Avatar answered Nov 06 '22 06:11

J_H