Ticket #3413: jython-threadable.diff

File jython-threadable.diff, 608 bytes (added by tkanerva, 13 months ago)

a workaround for jython thread module to find the thread ID

  • twisted/python/threadable.py

    diff --git a/twisted/python/threadable.py b/twisted/python/threadable.py
    index c75847d..e219c3f 100644
    a b _dummyID = object() 
    104104def getThreadID(): 
    105105    if threadingmodule is None: 
    106106        return _dummyID 
    107     return threadingmodule.currentThread().ident 
     107    try: 
     108        ident = threadingmodule.currentThread().ident 
     109    except AttributeError: 
     110        # in the case of Jython, there is no ident property, so return hashCode 
     111        ident = threadingmodule.currentThread()._thread.hashCode() 
     112    return ident 
    108113 
    109114 
    110115