Closed godlygeek closed 4 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 93.06%. Comparing base (
41248ed
) to head (41ce62f
). Report is 103 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
We switched from
pthread_atfork
handlers toos.register_at_fork
ones in order to support Python 3.13, where a lock that our child fork handler needs to acquire will not have been reinitialized in the child process at the time whenpthread_atfork
handlers run but will be reinitialized by the timeos.register_at_fork
handlers run.Unfortunately, this means that if a process forks without calling the
before
handler registered withos.register_at_fork
(as happens when using the "spawn" start method for multiprocessing, the default on macOS), then our hooks are unexpectedly still active from the time the process forks until the time that it execs another process image.We can work around this by using a mix of both
pthread_atfork
andos.register_at_fork
handlers: we suspend tracking in apthread_atfork
prepare handler, resume it in apthread_atfork
handler in the parent process, and (if--follow-fork
mode is used) we reinitialize it in the child process from anos.register_at_fork
child handler, after the interpreter's locks have been reinitialized.Closes: #642