-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
The function is like Py_AtExit() but for a single interpreter. This is a companion to the atexit module's register() function, taking a C callback instead of a Python one. We also update the _xxinterpchannels module to use _Py_AtExit(), which is the motivating case. (This is inspired by pain points felt while working on gh-101660.)
- Loading branch information
1 parent
4ec8dd1
commit 03089fd
Showing
13 changed files
with
269 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef Py_INTERNAL_ATEXIT_H | ||
#define Py_INTERNAL_ATEXIT_H | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef Py_BUILD_CORE | ||
# error "this header requires Py_BUILD_CORE define" | ||
#endif | ||
|
||
|
||
//############### | ||
// runtime atexit | ||
|
||
typedef void (*atexit_callbackfunc)(void); | ||
|
||
struct _atexit_runtime_state { | ||
#define NEXITFUNCS 32 | ||
atexit_callbackfunc callbacks[NEXITFUNCS]; | ||
int ncallbacks; | ||
}; | ||
|
||
|
||
//################### | ||
// interpreter atexit | ||
|
||
struct atexit_callback; | ||
typedef struct atexit_callback { | ||
atexit_datacallbackfunc func; | ||
void *data; | ||
struct atexit_callback *next; | ||
} atexit_callback; | ||
|
||
typedef struct { | ||
PyObject *func; | ||
PyObject *args; | ||
PyObject *kwargs; | ||
} atexit_py_callback; | ||
|
||
struct atexit_state { | ||
atexit_callback *ll_callbacks; | ||
atexit_callback *last_ll_callback; | ||
|
||
// XXX The rest of the state could be moved to the atexit module state | ||
// and a low-level callback added for it during module exec. | ||
// For the moment we leave it here. | ||
atexit_py_callback **callbacks; | ||
int ncallbacks; | ||
int callback_len; | ||
}; | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* !Py_INTERNAL_ATEXIT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.