Hello list,

I need to implement a graceful shutdown procedure for a twistd application.
The application is made up of two services: an internet.TCPClient and
an internet.TCPServer.
They're glued together with a MultiService instance, which is in turn set
to have 'application' as parent.
The server and the client work together, making a proxy (SMTP server and
AMQP client).

My goal is the following:
- intercept a SIGTERM signal
- 'block' on the server side: since it's SMTP I get this by setting a
variable that makes the server return tempfails (4xx) for new messages,
while keeping current sessions active
- wait until current requests are satisfied (I keep a dictionary of current
pending messages)
- shut the whole thing down

What is the best solution for this use case? It's not really clear to me
how to catch SIGTERM and handle pending requests *before* the underlying
services start to shutdown (i.e. even addSystemEventTrigger('before',
'shutdown', callable) is called too late for my needs).

Thank you very much for your help!

Fabio
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to