medusa as win32 service
Mark Hammond
mhammond at skippinet.com.au
Sun Nov 30 18:54:10 EST 2003
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 :)
Mark.
More information about the Python-list
mailing list