[Twisted-Python] deferToThread question
matt at pollenation.net
Fri Aug 20 03:32:56 MDT 2004
On Fri, 2004-08-20 at 10:07, Michele Petrazzo wrote:
> I want to call a block function. I use deferToThread to call it, so
> something like this:
> def block_func():
> os.popen3(my_soft) #my_soft is a blocking software
> print 1/0 # Simulate an error
I can't answer your threading question but Twisted supports async
process execution so you probably don't actually need a thread. See the
HOWTO, http://twistedmatrix.com/documents/current/howto/process, for
> If I use normal (not defer) call, so: block_func(), the exception is
> raised after my_soft is closed.
> I i call block_func with defer, so:
> def block_func_err(err):
> print err
> t = threads.deferToThread(block_func)
> the error is raised before my_soft is closed.
> Why? Is it right?
> S.O. win2k and mdk10, both with py 2.3.4, twisted 1.3.0, wxpy 2.4.2 and
> user of wxsupport, not wxreactor.
> Michele Petrazzo
Matt Goodall <matt at pollenation.net>
More information about the Twisted-Python