[Twisted-Python] Running twistd and tac files as Windows service

Michael Schlenker msc at contact.de
Wed Oct 24 07:33:26 EDT 2012

Am 24.10.2012 11:01, schrieb Phil Mayers:
> On 10/24/2012 08:43 AM, John Aherne wrote:
>> I don't have much idea about signalhandlers but I assume the one I am
>> interested in here is to stop ControlC. The others might need to stay
>> on. I'm not too sure about that without knowing more about windows
>> services and how they react to these signals.
> No, you need more than that removed. Otherwise you get a "signal" (can't 
> remember which - SIGBRK?) when the logged-in workstation logs off, which 
> terminates your twisted services. Very confusing.

There are no signals on windows.

But what you are talking about is the SetConsoleCtrlHandler function.

Thats relevant if your process has a console, e.g. is not a GUI app.
(pythonw.exe vs. python.exe). If you run as a GUI app you might get a
WM_QUERYENDSESSION or similar message.

You get a CTRL_LOGOFF_EVENT when a user on the machine logs off and you
run as a subprocess of a service and need to ignore it. The service
itself should deal with this already.


Michael Schlenker
Software Architect

CONTACT Software GmbH           Tel.:   +49 (421) 20153-80
Wiener Straße 1-3               Fax:    +49 (421) 20153-41
28359 Bremen
http://www.contact.de/          E-Mail: msc at contact.de

Sitz der Gesellschaft: Bremen
Geschäftsführer: Karl Heinz Zachries, Ralf Holtgrefe
Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215

More information about the Twisted-Python mailing list