[Medusa-dev] Stopping a Medusa Server
Giles Brown
giles_brown at hotmail.com
Wed Nov 19 03:29:06 EST 2003
>
>Hi,
>
>First post ...
>
>Is there a way to method on a Medusa server that is similar to the
>twisted.internet.main.shutDown() method?
>
>I'd like to run an xmlrpc server using Medusa as a Windows service, and
>have
>that service shut things down gracefully, waiting for Medusa to finish any
>database stuff before stopping.
>
>I've quickly read through the Medusa sources (http_server,
>asyncore.dispatcher) but I didn't find any likely candidates.
>
>If there is no such method now, how would you add one? If it's not too
>complicated, I could attempt a patch ...
>
>Regards,
Stopping an asyncore event loop from within a handler is as simple as:
def raise_exit(self):
"""Triggers exiting of event loop."""
raise asyncore.ExitNow
Getting it into a handler from another thread is harder. If you try and
use the medusa.thread.select_trigger to transfer it into the main thread,
the handle_read method catches *all* exceptions (even
asyncore.ExitNow). If you modify it to not catch this particular exception
everything is ok. So IMHO the only change needed is to alter
"handle_read" in medusa.thread.select_trigger to avoid catching (or
re-raise) asyncore.ExitNow.
Hth,
Giles
_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger
http://www.msn.co.uk/messenger
More information about the Medusa-dev
mailing list