mirror of
https://github.com/python/cpython.git
synced 2026-01-06 07:22:09 +00:00
Issue #28003: Implement PEP 525 -- Asynchronous Generators.
This commit is contained in:
parent
b96ef55d49
commit
eb6364557f
27 changed files with 2189 additions and 96 deletions
|
|
@ -25,6 +25,10 @@ PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
|
|||
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
|
||||
PyAPI_FUNC(void) _PyEval_SetCoroutineWrapper(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyEval_GetCoroutineWrapper(void);
|
||||
PyAPI_FUNC(void) _PyEval_SetAsyncGenFirstiter(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFirstiter(void);
|
||||
PyAPI_FUNC(void) _PyEval_SetAsyncGenFinalizer(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFinalizer(void);
|
||||
#endif
|
||||
|
||||
struct _frame; /* Avoid including frameobject.h */
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ typedef struct {
|
|||
``async def`` keywords) */
|
||||
#define CO_COROUTINE 0x0080
|
||||
#define CO_ITERABLE_COROUTINE 0x0100
|
||||
#define CO_ASYNC_GENERATOR 0x0200
|
||||
|
||||
/* These are no longer used. */
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -61,6 +61,37 @@ PyObject *_PyAIterWrapper_New(PyObject *aiter);
|
|||
PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
|
||||
PyAPI_FUNC(PyObject *) PyCoro_New(struct _frame *,
|
||||
PyObject *name, PyObject *qualname);
|
||||
|
||||
/* Asynchronous Generators */
|
||||
|
||||
typedef struct {
|
||||
_PyGenObject_HEAD(ag)
|
||||
PyObject *ag_finalizer;
|
||||
|
||||
/* Flag is set to 1 when hooks set up by sys.set_asyncgen_hooks
|
||||
were called on the generator, to avoid calling them more
|
||||
than once. */
|
||||
int ag_hooks_inited;
|
||||
|
||||
/* Flag is set to 1 when aclose() is called for the first time, or
|
||||
when a StopAsyncIteration exception is raised. */
|
||||
int ag_closed;
|
||||
} PyAsyncGenObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyAsyncGen_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyAsyncGenASend_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyAsyncGenWrappedValue_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyAsyncGenAThrow_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyAsyncGen_New(struct _frame *,
|
||||
PyObject *name, PyObject *qualname);
|
||||
|
||||
#define PyAsyncGen_CheckExact(op) (Py_TYPE(op) == &PyAsyncGen_Type)
|
||||
|
||||
PyObject *_PyAsyncGenValueWrapperNew(PyObject *);
|
||||
|
||||
int PyAsyncGen_ClearFreeLists(void);
|
||||
|
||||
#endif
|
||||
|
||||
#undef _PyGenObject_HEAD
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ PyAPI_FUNC(void) _PyGC_Fini(void);
|
|||
PyAPI_FUNC(void) PySlice_Fini(void);
|
||||
PyAPI_FUNC(void) _PyType_Fini(void);
|
||||
PyAPI_FUNC(void) _PyRandom_Fini(void);
|
||||
PyAPI_FUNC(void) PyAsyncGen_Fini(void);
|
||||
|
||||
PyAPI_DATA(PyThreadState *) _Py_Finalizing;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -148,6 +148,9 @@ typedef struct _ts {
|
|||
Py_ssize_t co_extra_user_count;
|
||||
freefunc co_extra_freefuncs[MAX_CO_EXTRA_USERS];
|
||||
|
||||
PyObject *async_gen_firstiter;
|
||||
PyObject *async_gen_finalizer;
|
||||
|
||||
/* XXX signal handlers should also be here */
|
||||
|
||||
} PyThreadState;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ typedef struct _symtable_entry {
|
|||
unsigned ste_child_free : 1; /* true if a child block has free vars,
|
||||
including free refs to globals */
|
||||
unsigned ste_generator : 1; /* true if namespace is a generator */
|
||||
unsigned ste_coroutine : 1; /* true if namespace is a coroutine */
|
||||
unsigned ste_varargs : 1; /* true if block has varargs */
|
||||
unsigned ste_varkeywords : 1; /* true if block has varkeywords */
|
||||
unsigned ste_returns_value : 1; /* true if namespace uses return with
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue