issue #477: more 2.4-compatible thread.get_ident() use.

issue510
David Wilson 5 years ago
parent a1e0b4381f
commit 881dc7d5ca

@ -2185,7 +2185,7 @@ class Waker(BasicStream):
:raises mitogen.core.Error:
:meth:`defer` was called after :class:`Broker` has begun shutdown.
"""
if threading.currentThread().ident == self.broker_ident:
if thread.get_ident() == self.broker_ident:
_vv and IOLOG.debug('%r.defer() [immediate]', self)
return func(*args, **kwargs)
if self._broker._exitted:
@ -2631,7 +2631,6 @@ class Broker(object):
name='mitogen-broker'
)
self._thread.start()
self._waker.broker_ident = self._thread.ident
def start_receive(self, stream):
"""
@ -2766,6 +2765,8 @@ class Broker(object):
Broker thread main function. Dispatches IO events until
:meth:`shutdown` is called.
"""
# For Python 2.4, no way to retrieve ident except on thread.
self._waker.broker_ident = thread.get_ident()
try:
while self._alive:
self._loop_once()

@ -53,6 +53,11 @@ import zlib
# Absolute imports for <2.5.
select = __import__('select')
try:
import thread
except ImportError:
import threading as thread
import mitogen.core
from mitogen.core import b
from mitogen.core import LOG
@ -1389,7 +1394,7 @@ class CallChain(object):
return '%s-%s-%x-%x' % (
socket.gethostname(),
os.getpid(),
threading.currentThread().ident,
thread.get_ident(),
int(1e6 * time.time()),
)

Loading…
Cancel
Save