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 win32serviceuti l, win32service,
class MeducaService(w in32serviceutil .ServiceFramewo rk):
_svc_name_ = "MedusaServ ice"
_svc_display_na me_ = "Medusa Service"
def __init__(self, args):
win32serviceuti l.ServiceFramew ork.__init__(se lf, args)
def SvcStop(self):
self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING)
print "Received Quit from Win32"
socket_map = asyncore.socket _map
while socket_map:
k, v = socket_map.popi tem()
try:
print "Shutting down",k,v
v.close()
except:
pass
del k, v
def SvcDoRun(self):
start_medusa()
--
Robin Becker
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 win32serviceuti l, win32service,
class MeducaService(w in32serviceutil .ServiceFramewo rk):
_svc_name_ = "MedusaServ ice"
_svc_display_na me_ = "Medusa Service"
def __init__(self, args):
win32serviceuti l.ServiceFramew ork.__init__(se lf, args)
def SvcStop(self):
self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING)
print "Received Quit from Win32"
socket_map = asyncore.socket _map
while socket_map:
k, v = socket_map.popi tem()
try:
print "Shutting down",k,v
v.close()
except:
pass
del k, v
def SvcDoRun(self):
start_medusa()
--
Robin Becker
Comment