[Python-bugs-list] [ python-Bugs-426735 ] [Linux] Threaded Python program hangs
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 29 May 2001 13:16:47 -0700
Bugs item #426735, was updated on 2001-05-23 12:56
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=426735&group_id=5470
Category: Python Interpreter Core
Group: Platform-specific
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Jeff Epler (jepler)
Assigned to: Nobody/Anonymous (nobody)
Summary: [Linux] Threaded Python program hangs
Initial Comment:
import thread, os, time
thread.start_new_thread(os._exit, (1,))
time.sleep(1)
print "done"
The program never prints "done".
Python 2.1 (tummy RPM 2.1-4)
RedHat 6.2
strace of the main thread shows:
select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)
rt_sigprocmask(SIG_SETMASK, NULL, [RT_0], 8) = 0
rt_sigsuspend([]
... Python completes the time.sleep() call, and then
hangs waiting something.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2001-05-29 13:16
Message:
Logged In: YES
user_id=31435
Use thread.exit() to abort a thread.
os._exit() is platform-dependent. On Linux it exits only
the thread that invokes it, and if that thread holds the
global interpreter lock at the time, all other threads will
hang. On Windows it kills off the process, and all threads
ever spawned by the process. I suspect other Unices behave
more like Windows than Linux here, but clear docs are hard
to find.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-05-28 18:52
Message:
Logged In: YES
user_id=31435
BTW, it doesn't print "done" for me on Win98 either, and I
didn't expect it to: _exit() is a "panic! stop the world!"
function.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-05-28 18:47
Message:
Logged In: YES
user_id=31435
Changed to platform-specific, since it Works For Me on
Win98SE. However, I'm not sure what "works" means: what
do the Linux docs say _exit should do when called from a
spawned thread? Does this program fail the same way if you
write it in C? It may have to do with that Python
implements time.sleep() on Linux via select(), to get fine
(r)-grained resolution.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=426735&group_id=5470