[Python-Dev] Python threads end up blocking signals in subprocesses (original) (raw)
Jeff Epler jepler at unpythonic.net
Wed Dec 17 18:31:26 EST 2003
- Previous message: [Python-Dev] bug in python arm-linux?: start_new_thread fails after popen
- Next message: [Python-Dev] Python threads end up blocking signals in subprocesses
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Dec 17, 2003 at 09:14:50AM -0600, Jeff Epler wrote:
There are also problems on redhat9, where signals in a fork+exec'd subprocess are blocked, for instance. This seemed to be a consequence of blocking all signals in threadpthread.h:PyThreadstartnewthread().
To follow up on my own message, here is a program that demonstrates the problem I ran into with threads and signals.
doit() uses system() to create a process that should kill itself with a signal nearly instantly, otherwise it sleeps for one second. If doit() is called from the main thread or before any threads are created, it prints a time well under 1 second. If it is run from a thread, it takes just over a second, because the delivery of the signal in the subprocess is blocked.
Typical output: $ python thread-signal-problem.py not threaded Elapsed time 0.00420594215393 subthread Elapsed time 1.00974297523 main thread Elapsed time 0.00419104099274
import thread, time, os
def doit(): t = time.time() os.system("kill ; sleep 1") t1 = time.time() print "Elapsed time", t1-t
print "not threaded" doit() print "subthread" thread.start_new(doit, ()) time.sleep(2) print "main thread" doit()
- Previous message: [Python-Dev] bug in python arm-linux?: start_new_thread fails after popen
- Next message: [Python-Dev] Python threads end up blocking signals in subprocesses
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]