medusa as win32 service

From: Robin Becker (robin_at_jessikat.fsnet.co.uk)
Date: 11/30/03


Date: Sun, 30 Nov 2003 18:03:19 +0000

I wonder if this is the right way to write a medusa(asyncore) server
with the win32all framework. Other example services seem to create an
event to pass the stop signal from SvcStop into a separate termination
method, but I'm unsure how that would mix with the polling loop.

This simple framework seems to start and stop OK, but I wonder if I'm
missing some obvious race or something.

import win32serviceutil, win32service,
class MeducaService(win32serviceutil.ServiceFramework):
    _svc_name_ = "MedusaService"
    _svc_display_name_ = "Medusa Service"
    def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)

    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        print "Received Quit from Win32"
        socket_map = asyncore.socket_map
        while socket_map:
            k, v = socket_map.popitem()
            try:
                print "Shutting down",k,v
                v.close()
            except:
                pass
            del k, v

    def SvcDoRun(self):
        start_medusa()

-- 
Robin Becker


Relevant Pages

  • Re: medusa as win32 service
    ... In article, Giles ... Brown writes ... >> with the win32all framework. ... >very well (we have a web server using medusa that runs as a service). ...
    (comp.lang.python)
  • Re: medusa as win32 service
    ... > with the win32all framework. ... medusa version) catches this exception. ... very well (we have a web server using medusa that runs as a service). ...
    (comp.lang.python)