Python Glossary Русский

Python 3.7+sysfunction

sys.get_coroutine_origin_tracking_depth()

asynchronous code

Returns how many stack frames are recorded in cr_origin when a coroutine is created; 0 means recording is off (the default).

Syntax

sys.get_coroutine_origin_tracking_depth()

A non-zero value usually means asyncio debug mode is on: inside asyncio.run(..., debug=True) the depth becomes positive and is restored on exit. Each thread has its own value. Without it a coroutine's cr_origin is None.

Examples

import asyncio, sys
print(sys.get_coroutine_origin_tracking_depth())  # → 0
async def main():
    print(sys.get_coroutine_origin_tracking_depth() > 0)
asyncio.run(main(), debug=True)  # → True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy