[Twisted-Python] how to cancel a long running job on a server ?

Thomas Jung Thomas.Jung at iisb.fraunhofer.de
Wed May 11 05:38:10 EDT 2005


On Tuesday 10 May 2005 16:28, Itamar Shtull-Trauring wrote:
> 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.
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python



Thanks !

I could not believe that you can even return a deferred from a remote server 
... thats really great !






More information about the Twisted-Python mailing list