[ python-Bugs-1562822 ] decimal module borks thread

SourceForge.net noreply at sourceforge.net
Fri Sep 22 19:56:54 CEST 2006


Bugs item #1562822, was opened at 2006-09-21 13:59
Message generated for change (Comment added) made by steevel
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1562822&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: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jaster (steevel)
Assigned to: Nobody/Anonymous (nobody)
Summary: decimal module borks thread

Initial Comment:
I got across this while trying to use MySQLdb in a
thread. Since MySQLdb imports decimal I got the same
error there.

Code: (This happens in both 2.4 and 2.5)

import thread, time, sys
if len(sys.argv) > 1:
   import threading

def test ():
   import decimal
   print 'Exiting test.'

thread.start_new_thread(test, ())
time.sleep(1)


Output:
$ ./thread.py 1
Exiting test.

$ ./thread.py
Exiting test.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/local/python2.5/lib/python2.5/atexit.py",
line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File
"/usr/local/python2.5/lib/python2.5/threading.py", line
656, in __exitfunc
    self._Thread__delete()
  File
"/usr/local/python2.5/lib/python2.5/threading.py", line
540, in __delete
    del _active[_get_ident()]
KeyError: -1209698640
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/local/python2.5/lib/python2.5/atexit.py",
line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File
"/usr/local/python2.5/lib/python2.5/threading.py", line
656, in __exitfunc
    self._Thread__delete()
  File
"/usr/local/python2.5/lib/python2.5/threading.py", line
540, in __delete
    del _active[_get_ident()]
KeyError: -1209698640

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

>Comment By: Jaster (steevel)
Date: 2006-09-22 19:56

Message:
Logged In: YES 
user_id=1117967

I don't get this interface. Why can't I post a comment?
To josiahcarlson: The program I'm currently writing is
module based and I don't know what python modules my users
will import. It shouldn't matter tho, either this is a "bug"
or it needs to go in the documentation that you can't import
them in a thread if you havent already imported them before.

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

Comment By: Josiah Carlson (josiahcarlson)
Date: 2006-09-22 05:48

Message:
Logged In: YES 
user_id=341410

I believe it is an issue with the import lock.

If you 'import decimal' prior to starting up your subthread,
everything will run fine.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1562822&group_id=5470


More information about the Python-bugs-list mailing list