import in execv after fork

R

Rotem

Hello,

We have been encountering several deadlocks in a threaded Python
application which calls subprocess.Popen (i.e. fork()) in some of its
threads.

This has occurred on Python 2.4.1 on a 2.4.27 Linux kernel.

Perliminary analysis of the hang shows that the child process blocks
upon entering the execvp function, in which the import_lock is acquired
due to the following line:

def _execvpe(file, args, env=None):
from errno import ENOENT, ENOTDIR
...

It is known that when forking from a pthreaded application, acquisition
attempts on locks which were already locked by other threads while
fork() was called will deadlock.

Due to these oddities I was wondering if it would be better to extract
the above import line from the execvpe call, to prevent lock
acquisition attempts in such cases.

I'd appreciate any opinions you might have on the subject.


Thanks in advance,

Rotem
 
R

Rotem

Another workaround could be re-assigning a new lock to import_lock
(such a thing is done with the global interpreter lock) at
PyOS_AfterFork or pthread_atfork.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top