Closed Nikratio closed 6 years ago
Curio is a volunteer project. Pull requests that address gaps in the documentation are certainly welcome.
Wrote a section of reference docs on the debugging options.
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.
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)?
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.
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)
https://curio.readthedocs.io/en/latest/reference.html#the-kernel says:
...but there is no debug section on that page, nor in the table of contents.