Issue2060

classification
Title: Thread ident missing
Type: Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: amak, oberstet, zyasoft
Priority: Keywords: patch

Created on 2013-06-12.08:02:34 by oberstet, last changed 2013-09-11.01:03:19 by zyasoft.

Files
File name Uploaded Description Edit Remove
threading_ident.diff santa4nt, 2013-06-12.18:30:42 Injecting the 'ident' property to threading.Thread objects.
Messages
msg8042 (view) Author: Tobias Oberstein (oberstet) Date: 2013-06-12.08:02:34
Thread identifier seems to be missing:

   C:\jython2.7b1\bin>jython
   Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
   [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import threading
   >>> threading.currentThread().ident
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   AttributeError: '_MainThread' object has no attribute 'ident'

This breaks Twisted 13.0 (already patched as described in http://twistedmatrix.com/trac/ticket/3413):

   Traceback (most recent call last):
     File "wstest", line 7, in <module>
       sys.exit(
     File "C:\jython2.7b1\Lib\site-packages\autobahntestsuite-0.5.4-py2.7.egg\autobahntestsuite\wstest.py", line 351, in run
       reactor.run()
     File "C:\jython2.7b1\Lib\site-packages\twisted-13.0.0-py2.7.egg\twisted\internet\base.py", line 1191, in run
       self.startRunning(installSignalHandlers=installSignalHandlers)
     File "C:\jython2.7b1\Lib\site-packages\twisted-13.0.0-py2.7.egg\twisted\internet\base.py", line 1171, in startRunning
       ReactorBase.startRunning(self)
     File "C:\jython2.7b1\Lib\site-packages\twisted-13.0.0-py2.7.egg\twisted\internet\base.py", line 687, in startRunning
       threadable.registerAsIOThread()
     File "C:\jython2.7b1\Lib\site-packages\twisted-13.0.0-py2.7.egg\twisted\python\threadable.py", line 122, in registerAsIOThread
       ioThread = getThreadID()
     File "C:\jython2.7b1\Lib\site-packages\twisted-13.0.0-py2.7.egg\twisted\python\threadable.py", line 107, in getThreadID
       return threadingmodule.currentThread().ident
   AttributeError: '_MainThread' object has no attribute 'ident'   

As a workaround, patch `twisted.python.threadable.py` for

   _dummyID = object()
   def getThreadID():
       if threadingmodule is None:
           return _dummyID
       try:
           # workaround for broken Jython
           tid = threadingmodule.currentThread().ident
           return tid
       except AttributeError:
           return _dummyID
msg8069 (view) Author: Jim Baker (zyasoft) Date: 2013-07-19.19:08:07
Verified; note that we are currently skipping a test that tests this functionality (test_threading.test_various_ops)

http://docs.python.org/2/library/threading.html#threading.Thread.ident reports this was added in 2.6, so it's just a gap in getting that implemented.
msg8070 (view) Author: Jim Baker (zyasoft) Date: 2013-07-19.22:37:48
Fixed in 7112:9ad4f341f030
msg8107 (view) Author: Alan Kennedy (amak) Date: 2013-09-07.13:47:10
If this is fixed, does the bug report need to be left open?
msg8112 (view) Author: Jim Baker (zyasoft) Date: 2013-09-11.01:03:19
My bad, now closed.
History
Date User Action Args
2013-09-11 01:03:19zyasoftsetstatus: open -> closed
messages: + msg8112
2013-09-07 13:47:10amaksetnosy: + amak
messages: + msg8107
2013-07-19 22:37:48zyasoftsetresolution: accepted -> fixed
messages: + msg8070
2013-07-19 19:08:08zyasoftsetassignee: zyasoft
resolution: accepted
messages: + msg8069
nosy: + zyasoft
2013-06-12 18:30:43santa4ntsetfiles: + threading_ident.diff
keywords: + patch
2013-06-12 08:02:35oberstetcreate