[Twisted-Python] Re: SIGBREAK on windows

Ralf Schmitt ralf at brainbot.com
Wed Sep 27 02:32:39 MDT 2006


Jacob Gabrielson wrote:
> Hi,
>  
> Has anyone run into a problem where their Twisted application gets a
> SIGBREAK and shuts down, on Windows?  I have a simple application using
> the ReconnectingClientFactory, running as a service (via srvany.exe),
> that occasionally dies with a few messages:
> 
> 2006/09/24 16:46 Pacific Daylight Time [-] Received SIGBREAK, shutting
> down.
> 2006/09/24 16:46 Pacific Daylight Time [AgentProtocol,client]
> <twisted.internet.tcp.Connector instance at 0x00A1B468> will retry in 2
> seconds
> 2006/09/24 16:46 Pacific Daylight Time [AgentProtocol,client] Stopping
> factory <twisted.internet.protocol.ReconnectingClientFactory instance at
> 0x00A10D28>
> 2006/09/24 16:46 Pacific Daylight Time [-] Main loop terminated.  
> 
> There's not a lot to go on, but I'm wondering if this is something
> anyone else has run into on Windows.  I'm not really sure how a SIGBREAK
> could get generated there in the first place.
>  

You may receive that signal when users log off. I'm using the following
code to ignore signals when running as service (but I'm also using the
win32serviceutil module to start as a service).

import win32api

def sighandler(sig):
    print "received signal %s" % (sig,)
    return True

win32api.SetConsoleCtrlHandler(sighandler, True)

However, I guess that if you're using that code unchanged you might not
be able to stop your service anymore.

More Information can be found at msdn:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setconsolectrlhandler.asp

You might also want to look into using the win32service module. IMHO,
it's a lot easier to handle than srvany. I'm attaching our nbsvc program
as example, which we use to start our programs as NT services.

Regards,
- Ralf


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: nbsvc
URL: </pipermail/twisted-python/attachments/20060927/f4b00e5e/attachment.ksh>


More information about the Twisted-Python mailing list