[Twisted-Python] waiting for data before shutdown

Andreas Poisel a.poisel at acat.cc
Tue Sep 25 14:27:06 EDT 2007


My client is supposed to wait for two seconds to receive data when a
shutdown event is triggered.  In buildProtocol() the trigger is added:

    self.sdt= reactor.addSystemEventTrigger('before', 'shutdown', protocol.shutdown)

The method shutdown() is supposed to wait for 2 seconds before closing
the connection:

    def shutdown(self):
        self.doSomeCleanup() # works
        self.sendSomeData()  # works
        d= defer.Deferred()
        reactor.callLater(2.0, d.callback, None)
        return d

The shutdown() method gets called, cleanup and sending of data work as
expected.  But the connection is closed by my client _before_ the two
seconds are over.  Isn't the shutdown process supposed to be halted
until the deferred returned by shutdown() is fired?

Thank you!
Bye, Andreas

More information about the Twisted-Python mailing list