Bugs item #1175202, was opened at 2005-04-01 21:24
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1175202&group_id=5470

Category: Threads
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeff Stearns (jeffstearns)
Assigned to: Nobody/Anonymous (nobody)
Summary: python hangs if import statement launches threads

Initial Comment:
(This bug looks similar to bug 1175194, but reports a different 
problem.)

I have a simple module which launches multiple HTTP client threads.

The main thread creates 10 HTTP clients, each of which fetches 
documents from a web server.  The main thread then simply goes to 
sleep while the client threads work. The threads are launched when 
the module is imported.

If I launch the script via
  python bug1.py
it launches and runs OK.

But if I launch the script via
  python -c 'import bug1'
it runs a bit, then hangs.

Here's an example:

[EMAIL PROTECTED]> ./python -c 'import bug1'
Using 10 threads
cccccccccc  <- [program hangs here]

Each thread prints a character every time that it does something 
interesting.  The 'c' characters indicate that a connect syscall was 
made.  These should be followed by 'C', indicating the the connect 
returned.  That never happens.

You might argue that it's inappropriate to launch threads from within  
import statement, but I can't find a specific prohibition against it.

Here's a trace of the last few syscalls before it hangs (pids are 
actually thread ids):
[pid 15481] futex(0x820cc48, FUTEX_WAKE, 1) = 0
[pid 15481] futex(0x8148698, FUTEX_WAIT, 0, NULL <unfinished ...>
[pid 15482] futex(0x81a9a80, FUTEX_WAKE, 1) = 0
[pid 15482] futex(0x820cc48, FUTEX_WAKE, 1) = 0
[pid 15482] write(2, "c", 1c)            = 1
[pid 15482] futex(0x820cc48, FUTEX_WAKE, 1) = 0
[pid 15482] futex(0x820cc48, FUTEX_WAKE, 1) = 0
[pid 15482] futex(0x8148698, FUTEX_WAIT, 0, NULL  <- hangs here

Please note that this bug is similar to bug 1175194, but reports a 
different problem.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1175202&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to