Yes, I do use the threading module, but it's not quite that simple. Some of my threads are actually running Java code, for PyLucene.
This is part of UpLib, at http://uplib.parc.com/. Thanks for the pointers. Is there a home site for rpdb2? Or is it just part of winpdb? The nice thing about gdb is that it doesn't need to be "on top"; you can attach to a server you started without any magic invocation. UpLib has a complicated startup dance, and it's hard to start it with the kind of invocation needed for debuggers like rpdb2. Bill ---------------------------------------------------------------- THREADING = None HAVE_PYLUCENE = None if "@USE_PYLUCENE@" == "jcc": # make sure the JVM DLL is on our path, a side-effect of finding the JAVAHOME find_JAVAHOME() HAVE_PYLUCENE = "jcc" THREADING = "python" class JavaCapableThread(threading.Thread): def run(self): if uthread.JAVA_ENV: uthread.JAVA_ENV.attachCurrentThread(self.getName(), self.isDaemon()) super(JavaCapableThread, self).run() if uthread.JAVA_ENV: uthread.JAVA_ENV.detachCurrentThread() class uthread: conf = configurator.default_configurator() maxheap = conf.get("java-max-heap", "512m") maxstack = conf.get("java-max-stack", "100m") vmargs = conf.get("java-vm-args", "-Djava.awt.headless=true") def initialize(cls): import lucene cls.JAVA_ENV = lucene.getVMEnv() or lucene.initVM(classpath=lucene.CLASSPATH, vmargs=cls.vmargs, initialheap="64m", maxheap=cls.maxheap, maxstack=cls.maxstack) # make sure we can call in on the main thread cls.JAVA_ENV.attachCurrentThread(threading.currentThread().getName(), threading.currentThread().isDaemon()) initialize=classmethod(initialize) def get_ident(): return repr(threading.currentThread()) get_ident = staticmethod(get_ident) def create_new_thread(name, fn, args): t = JavaCapableThread(None, fn, name, args) note(0, "creating new thread %s", t) t.setDaemon(true) return t create_new_thread=staticmethod(create_new_thread) def start_new_thread(fn, args, name=None): t = JavaCapableThread(None, fn, name, args) note(0, "starting new thread %s", t) t.setDaemon(true) t.start() return t start_new_thread = staticmethod(start_new_thread) def allocate_lock(): return threading.RLock() allocate_lock = staticmethod(allocate_lock) if (not HAVE_PYLUCENE): THREADING = "python" class uthread: def initialize(cls): pass initialize=classmethod(initialize) def get_ident(): return repr(threading.currentThread()) get_ident = staticmethod(get_ident) def create_new_thread(name, fn, args): t = threading.Thread(None, fn, name, args) t.setDaemon(true) note(0, "creating new thread %s", t) return t create_new_thread=staticmethod(create_new_thread) def start_new_thread(fn, args, name=None): t = threading.Thread(None, fn, name, args) t.setDaemon(true) note(0, "starting new thread %s", t) t.start() return t start_new_thread = staticmethod(start_new_thread) def allocate_lock(): return threading.RLock() allocate_lock = staticmethod(allocate_lock) Leonardo Santagada <santag...@gmail.com> wrote: > On Jun 2, 2009, at 1:18 PM, Bill Janssen wrote: > > > Actually, I'm debugging Python code, but it's running in a > > multi-threaded Python server. So I need to attach with gdb to see > > what's going on. It would be nice if "Thread Viewer" had the ability > > to decode Python stack traces. > > > > Thanks for the info. I'll try building using the Apple sources. > > > Is the "server" a multi-threaded python program, using thread or > Threading? Then I think you could use rpdb2 or winpdb to debug it. > > > -- > Leonardo Santagada > santagada at gmail.com > > > _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig