[Twisted-Python] how to cancel a long running job on a server ?
Itamar Shtull-Trauring
itamar at itamarst.org
Tue May 10 08:28:40 MDT 2005
On Tue, 2005-05-10 at 12:26 +0200, Thomas Jung wrote:
> I have a server, where I can remotely call a function like remote_calc(),
> using the perspective broker,
> which returns giving a result.
> Sometimes, I want to cancel that computation, calling e.g. remote_cancel()
> (which remains to be implemented.....)
>
> How can I have remote_calc() not to return before the result is done, and
> still be able to call remote_cancel while its running ?
> def remote_calc(self,result):
> print "server::calc: ..."
>
> # thought this would wait until done, but doesnt....
>
> calc(threads.deferToThread(do_calc))
> print "server::calc: returning"
> return 123
You probably want to return the result of calc() here - if you return
deferred from PB function it will know not to return until Deferred has
result.
More information about the Twisted-Python
mailing list