[Python-Dev] Re: Hang with parallel make

2020-02-26 Thread Elad Lahav
More information: The hang happens when building extensions, using the setup.py script. The script determines that the build is parallel (build_ext.py/build_extensions) and creates a thread pool. Each thread then executes a compilation job by fork()ing a compiler process. I don't see how it wor

[Python-Dev] Re: Hang with parallel make

2020-02-26 Thread Elad Lahav
Sorry, should have posted the backtrace from the beginning. It goes deeper than this, but the important part is in the child after fork(): #0 SyncSemWait () at /builds/workspace/710-SDP/build_x86_64/lib/c/kercalls/x86_64/SyncSemWait.S:37 #1 0x004bfa174ac6 in PyThread_acquire_lock_timed (l

[Python-Dev] Re: Hang with parallel make

2020-02-26 Thread Elad Lahav
It's actually not clear to me what lock it is from the core file I took, as rlock_acquire() is called through a function pointer from method_vectorcall_VARARGS_KEYWORDS() (I posted the backtrace separately). My suspicion is that it doesn't fail on macOS because it may keep all of the semaphore'

[Python-Dev] Re: Hang with parallel make

2020-02-26 Thread Elad Lahav
A change to posix_spawnp() fixes the problem for me: diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py index ceb94945dc..cb69de4242 100644 --- a/Lib/distutils/spawn.py +++ b/Lib/distutils/spawn.py @@ -90,7 +90,7 @@ def _spawn_posix(cmd, search_path=1, verbose=0, dry

[Python-Dev] Re: Hang with parallel make

2020-02-26 Thread Elad Lahav
A simple example that reproduces the hang (please keep in mind that I have very little experience writing Python code...): import os from concurrent.futures import ThreadPoolExecutor def new_process(arg): pid = os.fork() if pid == 0: exec_fn("/bin/true

[Python-Dev] Re: Hang with parallel make

2020-02-26 Thread Elad Lahav
I believe that the problem is in logging/__init__.py, which registers an atfork() handler for re-initializing its lock. However, as part of this process it attempts to acquire the module lock, which has not been reinitialized and so still reflects the parent's state of the lock. --Elad

[Python-Dev] Re: Hang with parallel make

2020-02-26 Thread Elad Lahav
Done. Thanks, --Elad ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list