mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-40089: Add _at_fork_reinit() method to locks (GH-19195)
Add a private _at_fork_reinit() method to _thread.Lock, _thread.RLock, threading.RLock and threading.Condition classes: reinitialize the lock after fork in the child process; reset the lock to the unlocked state. Rename also the private _reset_internal_locks() method of threading.Event to _at_fork_reinit(). * Add _PyThread_at_fork_reinit() private function. It is excluded from the limited C API. * threading.Thread._reset_internal_locks() now calls _at_fork_reinit() on self._tstate_lock rather than creating a new Python lock object.
This commit is contained in:
parent
48b069a003
commit
87255be696
7 changed files with 133 additions and 22 deletions
|
@ -36,6 +36,15 @@ PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int);
|
|||
#define WAIT_LOCK 1
|
||||
#define NOWAIT_LOCK 0
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifdef HAVE_FORK
|
||||
/* Private function to reinitialize a lock at fork in the child process.
|
||||
Reset the lock to the unlocked state.
|
||||
Return 0 on success, return -1 on error. */
|
||||
PyAPI_FUNC(int) _PyThread_at_fork_reinit(PyThread_type_lock *lock);
|
||||
#endif /* HAVE_FORK */
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
/* PY_TIMEOUT_T is the integral type used to specify timeouts when waiting
|
||||
on a lock (see PyThread_acquire_lock_timed() below).
|
||||
PY_TIMEOUT_MAX is the highest usable value (in microseconds) of that
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue