On 12:36 pm, sangiovanni@nweb.it wrote:All 'before' trigger are run concurrently. If you're using `Application` then your `sleep` trigger runs concurrently with the application's `stopService` trigger (because `Application` has its stopService added as another 'before' shutdown' trigger alongside yours).
On Thu, Sep 4, 2014 at 2:02 PM, <exarkun@twistedmatrix.com> wrote:
You said before shutdown triggers are too late but you didn't say why. I
think that's based on a misunderstanding - but if not, then explain why it
doesn't work for your scenario.
Hi, thanks for your reply.
I've tried the following:
def sleep(secs):
log.msg('from within trigger')
d = defer.Deferred()
reactor.callLater(secs, d.callback, None)
return d
reactor.addSystemEventTrigger('before', 'shutdown', sleep, 10)
If you want to delay your application shutdown, you need to cooperate a little more closely with it. Either attach your application shutdown code as a callback to the sleep Deferred or move the sleep into the stopService implementation of one of the services on your application and trigger the remaining stopService calls (eg the stopService call on the MultiService you mentioned) when the sleep Deferred fires there.
Jean-Paul
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python