no current thread warning
dgrisby at uk.research.att.com
Sat Dec 16 15:12:13 CET 2000
In article <91dtv0$g93$1 at panix6.panix.com>, Aahz Maruch <aahz at panix.com> wrote:
># Dummy thread class to represent threads not started here.
># These aren't garbage collected when they die,
># nor can they be waited for.
This behaviour is a problem for any C / C++ code which creates its own
threads, then calls into Python. It would be nice if threading.py
contained a proper API for creating and deleting threading.Thread
objects for threads created outside of Python.
In omniORBpy, I have exactly this problem. The work-around is to
create my own threading.Thread objects, and manually manipulate the
threading._active dictionary. That's ugly because it depends on the
threading module's internal structure. The Python code to do it is
below. The C++ side caches the Thread objects so they don't have to be
created on each up-call from C++ to Python.
# WorkerThread class used to make the threading module happy during
# operation dispatch.
# *** Depends on threading module internals ***
self._Thread__started = 1
self.id = threading._get_ident()
self.add = 0
self.add = 1
threading._active[self.id] = self
def _set_daemon(self): return 1
-- Duncan Grisby \ Research Engineer --
-- AT&T Laboratories Cambridge --
-- http://www.uk.research.att.com/~dpg1 --
More information about the Python-list