(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:
jps@cure> ./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.
|