Message365165
_at_fork() has a bug: it creates a _DummyThread instead of a _MainThread. Example:
---
import os, _thread, threading, time
def fork_in_thread():
pid = os.fork()
if pid:
# parent
os._exit(0)
# child process
print(f"child process: {threading.current_thread()=}")
print(f"child process: {threading._main_thread=}")
print(f"parent process: {threading.current_thread()=}")
print(f"parent process: {threading._main_thread=}")
_thread.start_new_thread(fork_in_thread, ())
# block the main thread: fork_in_thread() exit the process
time.sleep(60)
---
Output:
---
parent process: threading.current_thread()=<_MainThread(MainThread, started 139879200077632)>
parent process: threading._main_thread=<_MainThread(MainThread, started 139879200077632)>
child process: threading.current_thread()=<_DummyThread(Dummy-1, started daemon 139878980245248)>
child process: threading._main_thread=<_DummyThread(Dummy-1, started daemon 139878980245248)>
---
My PR 19191 fix the issue:
---
parent process: threading.current_thread()=<_MainThread(MainThread, started 140583665170240)>
parent process: threading._main_thread=<_MainThread(MainThread, started 140583665170240)>
child process: threading.current_thread()=<_MainThread(MainThread, started 140583445075712)>
child process: threading._main_thread=<_MainThread(MainThread, started 140583445075712)>
--- |
|
Date |
User |
Action |
Args |
2020-03-27 16:29:48 | vstinner | set | recipients:
+ vstinner, Batuhan Taskaya |
2020-03-27 16:29:48 | vstinner | set | messageid: <1585326588.57.0.914054012686.issue40089@roundup.psfhosted.org> |
2020-03-27 16:29:48 | vstinner | link | issue40089 messages |
2020-03-27 16:29:48 | vstinner | create | |
|