Bugs item #1175194, was opened at 2005-04-01 21:11
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1175194&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Threads
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeff Stearns (jeffstearns)
Assigned to: Nobody/Anonymous (nobody)
Summary: import statement likely to crash if module launches threads
Initial Comment:
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, and dies cleanly upon ^C.
But if I launch the script via
python -c 'import bug1'
it hangs at launch, and dumps core upon ^C.
Here's an example:
jps at cure> ./python -c 'import bug1'
Using 10 threads
cccccccccc <- [program hangs here]
Traceback (most recent call last):
File "<string>", line 1, in ?
File "test/bug1.py", line 55, in ?
run (10)
File "test/bug1.py", line 50, in run
time.sleep (30000)
KeyboardInterrupt
Fatal Python error: PyImport_GetModuleDict: no module dictionary!
Aborted (core dumped)
You might argue that it's inappropriate to launch threads from within
import statement, but I can't find a specific prohibition against it.
In any event, it shouldn't cause the interpreter to crash.
Please note that the crash isn't consistent. Sometimes the import
statement doesn't lead to a crash.
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2005-10-03 22:42
Message:
Logged In: YES
user_id=33168
Reproduced on Linux.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1175194&group_id=5470