[Twisted-Python] reactor.stop() and deferToThead
exarkun at divmod.com
Fri May 29 08:40:21 EDT 2009
On Fri, 29 May 2009 14:22:43 +0200, Thomas Jakobsen <thomas.jakobsen at alexandra.dk> wrote:
>It seems that things being deferredToThread continue to run even
>though reactor.stop() is called.
Threads cannot be interrupted. They will run until they function they are
>Output from the example below is:
>stuff1 finished; stopping reactor
>Is there a way to abort the remaining execution of stuff2 in this
>case? It would be handy if, say, some exception happens in in stuff1
>that causes the execution of the remaining stuff2 to be meaningless.
You can make stuff2 cooperate with stuff1 so that it returns earlier.
> print "stuff1 finished; stopping reactor"
Also, you're calling reactor.stop() in a non-reactor thread here. This is
not allowed. You must call it in the reactor thread, along with almost
every other API. Try reactor.callFromThread(reactor.stop), instead.
More information about the Twisted-Python