[Twisted-Python] Capture blocking calls?
luc.stepniewski at adelux.fr
Thu Jun 16 02:46:17 EDT 2005
On Wednesday 15 June 2005 03:17, Jp Calderone wrote:
> On Tue, 14 Jun 2005 17:45:54 -0700, Ian Duggan <ian at ianduggan.net> wrote:
> >Does anyone know of any tools that could be used to wrap a python module
> > and capture/report blocking calls made by it?
I've go tthe same difficulties here. I'm trying to integrate into Twisted a
method (which comes from a python+C compiled module) that returns data. The
problem is that this method is blocking, so I can't integrate it easily in
So what I would like to do is, in a perfect world (i think):
- Make an infinite loop in which I have this blocking method
- When some data is returned from that method call, do some stuff on it, like
call a PB remote method, call a deferred, adding callbacks (I mean I need/use
the reactor). This work would not be blocking (it shouldn't as it's twisted
stuff) as I need to get the results (callbacks).
- loop, etc.
My current solution is to use a separate thread for that blocking call,
keeping the main twisted reactor in the main process. I can call twisted
deferred by using the callFromThread() method, but the code is horribly big
(and slow) and complex, even using exarkun's ThreadWrapper (from sandbox) :-(
Is threadedselectreactor what I'm looking for? I did not really understand
what reactor.interleave() is supposed to call, as all I have is a method to
call which blocks...
More information about the Twisted-Python