Why is using the preexec function with Popen dangerous with threads

Viewed 64

The documentation for subprocess.Popen() has a warning:

Warning: The preexec_fn parameter is not safe to use in the presence of threads in your application. The child process could deadlock before exec is called.

Does it refer to the presence of threads in the application that calls Popen, or the application that is run via Popen?

I couldn't find a good explanation of why this should be so. Any help in that regard will be very useful.

My specific use for pre-exec function is to set soft limit for virtual memory via resource.setrlimit(). Could this possibly cause the deadlock mentioned in the warning?

0 Answers
Related