[ python-Bugs-1175194 ] import statement likely to crash if module
launches threads
SourceForge.net
noreply at sourceforge.net
Sat Apr 2 07:11:10 CEST 2005
Bugs item #1175194, was opened at 2005-04-01 21:11
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=1175194&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: 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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1175194&group_id=5470
More information about the Python-bugs-list
mailing list