Re: [Pydev-code] PyDev Debugger: Monkeypatch thread.start_new_thread to debug threads?
Brought to you by:
fabioz
From: Fabio Z. <fa...@es...> - 2010-02-21 18:55:14
|
On Sun, Feb 21, 2010 at 2:45 PM, Leo Soto M. <leo...@gm...> wrote: > Hi all, > > When running the Django server under the PyDev debugger there is a > problem: Under Jython the server spawns a worker thread which do all > the actual work while the main thread just keeps monitoring the > filesystem for changes. But, AFAICS, the pydev debugger only monitors > the main thread. > > I'm playing with monkey-patching thread.start_new_thread to set > sys.settrace to the internal settrace function used with PyDev when > executing the function in the new thread. > > Any obvious reason I'm missing why that may be a bad idea? Actually, Pydev should already trigger debugging in any thread (it sets the threading.settrace to do that). I believe django creates a separate process to do that, which is the reason the remote debugger must used for debugging django (a version without the reload feature should already work for all threads). What could be done is that the remote debugger is started and each new process calls pydevd.settrace(suspend=False, traceAllThreads=True), where traceAllThreads is a flag that is still not implemented, which calls threading.settrace(debugger.trace_dispatch) for all new threads -- not only the pydevd_tracing.SetTrace(debugger.trace_dispatch) -- and maybe pass the sys._current_frames to set the tracing for existing threads. If you think that'd be useful, I can create that option... Cheers, Fabio |