medusa as win32 service

Robin Becker robin at
Mon Dec 1 09:49:47 CET 2003

In article <bqdvv2$2m5u$1 at>, Mark Hammond
<mhammond at> writes
>Robin Becker wrote:
>> 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.
>SvcStop will be called on a different thread.  I don't know enough about 
>socket semantics to know if this is an issue.

>When I've tried to play with async based services, IIRC there were a few 
>problems if a connection existed at shutdown time.  If "close" could 
>ever block, then Windows would get quite upset.  If a "close()" ever 
>fails, then I guess there is a risk that the main loop will not 
>terminate, again making Windows upset.  But as above, I don't know 
>enough about the framework to comment on the risks here.
>So really, the issues are all Python related - the win32 interactions 
>appear OK, assuming close could never block.
>For the SpamBayes project, our framework needed a "clean shutdown" to 
>save our databases etc, so we ended up using urlopen to connect to a 
>special "shutdown" URL.  I didn't write that part, so I don't understand 
>if there was a better option.
>Hope this helps a little :)

it does indeed as I'm then into ensuring that the close methods are
reasonable. So I guess the problem reduces to whether the simple medusa
services ftp/http are cleanly terminatable.

As a matter of interest how does one get rid of LEGACY services? Whilst
getting the above going I seem to have created a LEGACY_MEDUSASERVICE in
the registry. All attempts at deletion fail. 


Robin Becker

More information about the Python-list mailing list