| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent eca7da0 commit f7ecfac
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -564,7 +564,7 @@ Additionally, when extending or embedding Python, calling :c:func:`fork` | |||
| 564 | 564 | directly rather than through :func:`os.fork` (and returning to or calling | |
| 565 | 565 | into Python) may result in a deadlock by one of Python's internal locks | |
| 566 | 566 | being held by a thread that is defunct after the fork. | |
| 567 | - :c:func:`PyOS_AfterFork` tries to reset the necessary locks, but is not | ||
| 567 | + :c:func:`PyOS_AfterFork_Child` tries to reset the necessary locks, but is not | ||
| 568 | 568 | always able to. | |
| 569 | 569 | ||
| 570 | 570 | ||
@@ -675,9 +675,9 @@ code, or when embedding the Python interpreter: | |||
| 675 | 675 | ||
| 676 | 676 | .. c:function:: void PyEval_ReInitThreads() | |
| 677 | 677 | ||
| 678 | - This function is called from :c:func:`PyOS_AfterFork` to ensure that newly | ||
| 679 | - created child processes don't hold locks referring to threads which | ||
| 680 | - are not running in the child process. | ||
| 678 | + This function is called from :c:func:`PyOS_AfterFork_Child` to ensure | ||
| 679 | + that newly created child processes don't hold locks referring to threads | ||
| 680 | + which are not running in the child process. | ||
| 681 | 681 | ||
| 682 | 682 | ||
| 683 | 683 | The following functions use thread-local storage, and are not compatible | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -166,6 +166,10 @@ Serhiy Storchaka in :issue:`28682`.) | |||
| 166 | 166 | Added support for :ref:`file descriptors <path_fd>` in :func:`~os.scandir` | |
| 167 | 167 | on Unix. (Contributed by Serhiy Storchaka in :issue:`25996`.) | |
| 168 | 168 | ||
| 169 | + New function :func:`os.register_at_fork` allows registering Python callbacks | ||
| 170 | + to be executed on a process fork. (Contributed by Antoine Pitrou in | ||
| 171 | + :issue:`16500`.) | ||
| 172 | + | ||
| 169 | 173 | unittest.mock | |
| 170 | 174 | ------------- | |
| 171 | 175 | ||
@@ -243,6 +247,11 @@ Build and C API Changes | |||
| 243 | 247 | * Added functions :c:func:`PySlice_Unpack` and :c:func:`PySlice_AdjustIndices`. | |
| 244 | 248 | (Contributed by Serhiy Storchaka in :issue:`27867`.) | |
| 245 | 249 | ||
| 250 | + * :c:func:`PyOS_AfterFork` is deprecated in favour of the new functions | ||
| 251 | + :c:func:`PyOS_BeforeFork`, :c:func:`PyOS_AfterFork_Parent` and | ||
| 252 | + :c:func:`PyOS_AfterFork_Child`. (Contributed by Antoine Pitrou in | ||
| 253 | + :issue:`16500`.) | ||
| 254 | + | ||
| 246 | 255 | ||
| 247 | 256 | Deprecated | |
| 248 | 257 | ========== | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1320,8 +1320,8 @@ def main_thread(): | |||
| 1320 | 1320 | ||
| 1321 | 1321 | def _after_fork(): | |
| 1322 | 1322 | # This function is called by Python/ceval.c:PyEval_ReInitThreads which | |
| 1323 | - # is called from PyOS_AfterFork. Here we cleanup threading module state | ||
| 1324 | - # that should not exist after a fork. | ||
| 1323 | + # is called from PyOS_AfterFork_Child. Here we cleanup threading module | ||
| 1324 | + # state that should not exist after a fork. | ||
| 1325 | 1325 | ||
| 1326 | 1326 | # Reset _active_limbo_lock, in case we forked while the lock was held | |
| 1327 | 1327 | # by another (non-forked) thread. http://bugs.python.org/issue874900 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1052,6 +1052,9 @@ Windows | |||
| 1052 | 1052 | C API | |
| 1053 | 1053 | ----- | |
| 1054 | 1054 | ||
| 1055 | + - bpo-16500: Deprecate PyOS_AfterFork() and add PyOS_BeforeFork(), | ||
| 1056 | + PyOS_AfterFork_Parent() and PyOS_AfterFork_Child(). | ||
| 1057 | + | ||
| 1055 | 1058 | - bpo-6532: The type of results of PyThread_start_new_thread() and | |
| 1056 | 1059 | PyThread_get_thread_ident(), and the id parameter of | |
| 1057 | 1060 | PyThreadState_SetAsyncExc() changed from "long" to "unsigned long". | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -232,10 +232,10 @@ PyEval_ReleaseThread(PyThreadState *tstate) | |||
| 232 | 232 | drop_gil(tstate); | |
| 233 | 233 | } | |
| 234 | 234 | ||
| 235 | - /* This function is called from PyOS_AfterFork to destroy all threads which are | ||
| 236 | - * not running in the child process, and clear internal locks which might be | ||
| 237 | - * held by those threads. (This could also be done using pthread_atfork | ||
| 238 | - * mechanism, at least for the pthreads implementation.) */ | ||
| 235 | + /* This function is called from PyOS_AfterFork_Child to destroy all threads | ||
| 236 | + * which are not running in the child process, and clear internal locks | ||
| 237 | + * which might be held by those threads. | ||
| 238 | + */ | ||
| 239 | 239 | ||
| 240 | 240 | void | |
| 241 | 241 | PyEval_ReInitThreads(void) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -194,7 +194,7 @@ _PyImport_ReleaseLock(void) | |||
| 194 | 194 | return 1; | |
| 195 | 195 | } | |
| 196 | 196 | ||
| 197 | - /* This function is called from PyOS_AfterFork to ensure that newly | ||
| 197 | + /* This function is called from PyOS_AfterFork_Child to ensure that newly | ||
| 198 | 198 | created child processes do not share locks with the parent. | |
| 199 | 199 | We now acquire the import lock around fork() calls but on some platforms | |
| 200 | 200 | (Solaris 9 and earlier? see isue7242) that still left us with problems. */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -800,7 +800,7 @@ _PyGILState_Fini(void) | |||
| 800 | 800 | autoInterpreterState = NULL; | |
| 801 | 801 | } | |
| 802 | 802 | ||
| 803 | - /* Reset the TLS key - called by PyOS_AfterFork(). | ||
| 803 | + /* Reset the TLS key - called by PyOS_AfterFork_Child(). | ||
| 804 | 804 | * This should not be necessary, but some - buggy - pthread implementations | |
| 805 | 805 | * don't reset TLS upon fork(), see issue #10517. | |
| 806 | 806 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -325,7 +325,7 @@ PyThread_delete_key_value(int key) | |||
| 325 | 325 | } | |
| 326 | 326 | ||
| 327 | 327 | /* Forget everything not associated with the current thread id. | |
| 328 | - * This function is called from PyOS_AfterFork(). It is necessary | ||
| 328 | + * This function is called from PyOS_AfterFork_Child(). It is necessary | ||
| 329 | 329 | * because other thread ids which were in use at the time of the fork | |
| 330 | 330 | * may be reused for new threads created in the forked process. | |
| 331 | 331 | */ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments