This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Calling os.fork() at Python exit logs: AttributeError: 'NoneType' object has no attribute '_at_fork_reinit'
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.10, Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: miss-islington, vstinner
Priority: normal Keywords: patch

Created on 2020-11-13 17:51 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 23268 merged vstinner, 2020-11-13 18:03
PR 23315 merged miss-islington, 2020-11-16 14:20
Messages (3)
msg380912 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-11-13 17:51
The following code logs an error:
Exception ignored in: <function _after_fork at 0x7f2bf3b057e0>
Traceback (most recent call last):
  File "/home/vstinner/python/master/Lib/", line 1508, in _after_fork
  File "/home/vstinner/python/master/Lib/", line 847, in _reset_internal_locks
AttributeError: 'NoneType' object has no attribute '_at_fork_reinit'

import atexit
import subprocess

def preexec():

def exit_handler():
    proc = subprocess.Popen(

if __name__ == "__main__":

It is a regression caused by the following bpo-40089 fix:

commit 87255be6964979b5abdc4b9dcf81cdcfdad6e753
Author: Victor Stinner <>
Date:   Tue Apr 7 23:11:49 2020 +0200

    bpo-40089: Add _at_fork_reinit() method to locks (GH-19195)
msg381099 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-11-16 14:20
New changeset 5909a494cd3ba43143b28bd439773ed85a485dfc by Victor Stinner in branch 'master':
bpo-42350: Fix Thread._reset_internal_locks() (GH-23268)
msg381109 - (view) Author: miss-islington (miss-islington) Date: 2020-11-16 15:17
New changeset cf70854f10096446115408b5a94030b30594a459 by Miss Islington (bot) in branch '3.9':
bpo-42350: Fix Thread._reset_internal_locks() (GH-23268)
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86516
2020-11-16 15:18:33vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-11-16 15:17:20miss-islingtonsetmessages: + msg381109
2020-11-16 14:20:51miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request22206
2020-11-16 14:20:42vstinnersetmessages: + msg381099
2020-11-13 18:03:38vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request22164
2020-11-13 17:51:36vstinnercreate