[Twisted-Python] Twisted and NT Services

screwtape at froup.com screwtape at froup.com
Mon Jun 23 21:31:53 EDT 2003

At $FIRM, a good number of processes around the place are Python
scripts using Twisted. Since they're functionally equivalent to Unix
daemons, what's the best way of turning a Twisted script into a

Also, I've gotten into the habit of using py2exe to turn scripts into
standalone Win32 programs, and it would be really nice to be able to
ship a standalone NT service. Unfortunately, there seems to be a "pick
any two" relationship between Twisted, NT Services, and py2exe - when
I try and combine all three, I get the following traceback inside my
Application.run() call:

      File "twisted\internet\app.pyc", line 861, in run
    --- <exception caught here> ---
      File "twisted\python\log.pyc", line 64, in callWithLogger
      File "twisted\python\log.pyc", line 51, in callWithContext
      File "twisted\python\context.pyc", line 32, in callWithContext
      File "twisted\internet\default.pyc", line 122, in run
      File "twisted\internet\default.pyc", line 116, in startRunning
      File "twisted\internet\default.pyc", line 88, in _handleSignals
    exceptions.ValueError: signal only works in main thread

If, in the Python source which contains the Service subclass, I put
(at the top):

	from twisted.internet import win32eventreactor

...and then make it into a service, I get the same error
(Entertainingly, if I put it *not* at the top, when I run the
resulting exe I get the entertaining dialog box "Could not get Script

As you might have gathered, I'm not using .taps for these services -
although I suspect they'd meet the 'don't reveal our source code to
random people' requirement, I suspect they wouldn't help with the
issue of installing Python and half a dozen extension modules on every

Anyone have any hints or suggestions?

 ___________ ____________________________
| Screwtape | Reply-To: munged on Usenet |________ ______ ____ __ _  _   _
| Nice sensible hobbits stay with Sméagol.

More information about the Twisted-Python mailing list