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 thread_pthread.h:PyThread_start_new_thread(). 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()
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