[Twisted-Python] Twisted and NT Services

Andrew Bennetts andrew-twisted at puzzling.org
Tue Jun 24 00:47:52 EDT 2003


On Tue, Jun 24, 2003 at 02:07:13PM +1000, screwtape at froup.com wrote:
> On Tue, Jun 24, 2003 at 12:54:32PM +1000, Andrew Bennetts wrote:
> > On Tue, Jun 24, 2003 at 11:31:53AM +1000, screwtape at froup.com wrote:
> > [...]
> > >     exceptions.ValueError: signal only works in main thread
> > 
> > Try passing installSignalHandlers=0 to Application.run to work around this.
> 
> Out of curiosity, does Win32 even have signal handlers? Or are these
> signal handlers something entirely different from the Unix concept?

Python does have a signal module on Win32, although I'm not sure what the
underlying Win32 API supports.
twisted.internet.default.PosixReactorBase._handleSignals might be
instructive, though:

    def _handleSignals(self):
        """Install the signal handlers for the Twisted event loop."""
        import signal
        signal.signal(signal.SIGINT, self.sigInt)
        signal.signal(signal.SIGTERM, self.sigTerm)

        # Catch Ctrl-Break in windows (only available in Python 2.2 and up)
        if hasattr(signal, "SIGBREAK"):
            signal.signal(signal.SIGBREAK, self.sigBreak)

        if platform.getType() == 'posix':
            signal.signal(signal.SIGCHLD, self._handleSigchld)

-Andrew.





More information about the Twisted-Python mailing list