A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-May/065051.html below:

[Python-Dev] pthreads, fork, import, and execvp

[Python-Dev] pthreads, fork, import, and execvp"Martin v. Löwis" martin at v.loewis.de
Thu May 18 20:02:06 CEST 2006
Nick Coghlan wrote:
> And if I understand it correctly, it falls under the category that
> waiting for another thread while holding the import lock is a *really*
> bad idea from a thread safety point of view.
> 
> The thing with the import-after-fork deadlock is that you can trigger it
> without even doing anything that's known not to be thread-safe.

Right. With some googling, I found that one solution is pthread_atexit:
a pthread_atexit handler is a triple (before, in_parent, in_child).
You set it to (acquire, release, release). When somebody forks,
the pthread library will first acquire the import lock in the thread
that wants to fork. Then the fork occurs, and the import lock gets
then released both in the parent and in the child.

I would like to see this approach implemented, but I agree with you
that a test case should be created first.

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4