dabeaz / curio

Good Curio!
Other
4.02k stars 241 forks source link

Debugging options not documented #241

Closed Nikratio closed 6 years ago

Nikratio commented 6 years ago

https://curio.readthedocs.io/en/latest/reference.html#the-kernel says:

debug is a list of optional debugging features. See the section on debugging for more detail.

...but there is no debug section on that page, nor in the table of contents.

dabeaz commented 6 years ago

Curio is a volunteer project. Pull requests that address gaps in the documentation are certainly welcome.

dabeaz commented 6 years ago

Wrote a section of reference docs on the debugging options.

goldcode commented 6 years ago

thanks for the documentation. i looked through https://curio.readthedocs.io/en/latest/reference.html#debugging-and-diagnostics which looks new to me but couldn't figure what i want to do, namely, get the list of currently running tasks and their callstacks. similar to what curio.monitor provides.

Use Case: During a device measurement there is a health check task which ascertains that the measurement is not hanging. if it does hang, the device is restarted and initiates a recovery mode. i.e. it continues running the measurement from where it left off.

Before the device is restarted, for logging it would be required to get the list of currently running (among them hanging) tasks and their call stacks for offline diagnosis.

dabeaz commented 6 years ago

Oh, that's an interesting possibility. Would the list of currently running tasks be obtained from within Curio (i.e., within a running Curio Task) or is the list being obtained from outside Curio (i.e., maybe from a separate thread)?

goldcode commented 6 years ago

in my use case it would suffice from within a curio task. i.e. if the health check task found some unhealthy symptoms, it logs all tasks and their call stacks.

dabeaz commented 6 years ago

Add a get_all_tasks() coroutine that returns a list of all active tasks. Tasks have a traceback() method that will return a formatted traceback showing where the task is executing. A where() method returns (filename, lineno) for a task. For example:

 for task in await get_all_tasks():
         filename, lineno = await task.where()
         print(task.name, filename, lineno)