[New-bugs-announce] [issue42350] Calling os.fork() at Python exit logs: AttributeError: 'NoneType' object has no attribute '_at_fork_reinit'

STINNER Victor report at bugs.python.org
Fri Nov 13 12:51:36 EST 2020


New submission from STINNER Victor <vstinner at python.org>:

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/threading.py", line 1508, in _after_fork
    thread._reset_internal_locks(True)
  File "/home/vstinner/python/master/Lib/threading.py", line 847, in _reset_internal_locks
    self._tstate_lock._at_fork_reinit()
AttributeError: 'NoneType' object has no attribute '_at_fork_reinit'
---

Code:
---
#!/usr/bin/python3
import atexit
import subprocess


def preexec():
    pass


def exit_handler():
    proc = subprocess.Popen(
        ["pwd"],
        preexec_fn=preexec,
    )
    proc.communicate()


if __name__ == "__main__":
    atexit.register(exit_handler)
---


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

commit 87255be6964979b5abdc4b9dcf81cdcfdad6e753
Author: Victor Stinner <vstinner at python.org>
Date:   Tue Apr 7 23:11:49 2020 +0200

    bpo-40089: Add _at_fork_reinit() method to locks (GH-19195)

----------
components: Library (Lib)
messages: 380912
nosy: vstinner
priority: normal
severity: normal
status: open
title: Calling os.fork() at Python exit logs: AttributeError: 'NoneType' object has no attribute '_at_fork_reinit'
versions: Python 3.10, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42350>
_______________________________________


More information about the New-bugs-announce mailing list