mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
bpo-32591: Add native coroutine origin tracking (#5250)
* Add coro.cr_origin and sys.set_coroutine_origin_tracking_depth * Use coroutine origin information in the unawaited coroutine warning * Stop using set_coroutine_wrapper in asyncio debug mode * In BaseEventLoop.set_debug, enable debugging in the correct thread
This commit is contained in:
parent
1211c9a989
commit
fc2f407829
20 changed files with 485 additions and 100 deletions
|
|
@ -31,6 +31,8 @@ PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
|
|||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
|
||||
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
|
||||
PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(int new_depth);
|
||||
PyAPI_FUNC(int) _PyEval_GetCoroutineOriginTrackingDepth(void);
|
||||
PyAPI_FUNC(void) _PyEval_SetCoroutineWrapper(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyEval_GetCoroutineWrapper(void);
|
||||
PyAPI_FUNC(void) _PyEval_SetAsyncGenFirstiter(PyObject *);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
|
|||
#ifndef Py_LIMITED_API
|
||||
typedef struct {
|
||||
_PyGenObject_HEAD(cr)
|
||||
PyObject *cr_origin;
|
||||
} PyCoroObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCoro_Type;
|
||||
|
|
|
|||
|
|
@ -262,6 +262,8 @@ typedef struct _ts {
|
|||
void (*on_delete)(void *);
|
||||
void *on_delete_data;
|
||||
|
||||
int coroutine_origin_tracking_depth;
|
||||
|
||||
PyObject *coroutine_wrapper;
|
||||
int in_coroutine_wrapper;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@ PyErr_WarnExplicitFormat(PyObject *category,
|
|||
#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
void _PyErr_WarnUnawaitedCoroutine(PyObject *coro);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue