[IPython-user] implementing non-blocking thread execution for something other than toolkits

Rohan Nicholls rohan.nicholls@googlemail....
Tue Mar 24 04:01:03 CDT 2009


On Thu, Mar 19, 2009 at 5:24 PM, Rohan Nicholls
<rohan.nicholls@googlemail.com> wrote:
>
> Sorry I just found this email.  I would be happy to, but it will take
> a few days
> to get it done, and I would like to experiment more with this first.

But before I do that having now experimented some more I have run into
these issues, that are very important to be aware of in docs, esp. if
I am missing something and there is already a solution for this.

It would seem that certain threaded applications, at the moment I am
doing a lot of work with webpy, are non debuggable with ipython, here
is an example.

I have a webpy script and I would like to set a breakpoint on line
299. I issue this command:

run -d -b299 myscript.py 8080

- I have also tried this with the bare -d and adding the line
  ipdb> b 299

- Then I hit c to continue and run the script.

- I refresh the browser page that will make the code run that I want
  to break into and the output shows that it is indeed processing that
  line, but no breaking into ipdb ever happens.

I have tried this on different lines, and made sure that there was
something happening on those lines.  I tried this in the bare pdb,
with the same non-result.

I have also tested this using the
bg _ip.magic('run -i myscript.py 8080')
line, but the debugger is never entered.  What surprised me is that

And it is actually worse than not being able to set breakpoints,
because it is also not catching exceptions in the code which are
happening on these other threads.

What I am trying to figure out is why does this work in things like
winpdb, eric4 and wing?  It would seem that they are tracking the
output of every thread or subverting all io to run
through some thread of their own, and looking for backtraces, at which point
they throw the bebugger on.  It would seem that ipython does
this with the -wthread flag, as exceptions are caught there and
processed, and I can set breakpoints and they work.

I have been reading the parallel computing docs, but this seems a lot
more than what is needed, but maybe that is the basis on which
-wthread is built.

Is there something I am missing, or should I be figuring out something
using the background_jobs.py file I have just stumbled on in the
source? At the moment I am having to jump into eric4 or wing to debug
these scripts, but would love to be able to stay in my familiar
environment and not have to be mousing around the place all the
time. :)

Thanks for any help with this,

Rohan


More information about the IPython-user mailing list