medusa as win32 service

Robin Becker robin at jessikat.fsnet.co.uk
Sun Nov 30 13:03:19 EST 2003


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




More information about the Python-list mailing list