[Medusa-dev] medusa & asyncore.loop -- termination & GUI

Hal Wine hal at dtor.com
Wed Apr 9 17:57:48 EDT 2003


Hi, all -- I've been trying to figure out how to wrap a medusa based 
app with a Tkinter GUI, and am stuck on clean termination. Seems like 
this would have come up before, but I can't find anything.

What I want to do is allow timely and clean termination of the main 
medusa based server from a GUI similar to the PyDoc GUI, in some ways.

This particular app has multiple calls to asyncore.loop 
(multi-threaded), so removing them and replacing with a call from 
Tkinter (ala the suggestion in the medusa/docs/tkinter.txt file) won't 
work. The app still needs to work from the command line, unaltered.

There are two issues I need to resolve:
1) initiating a clean termination (can't type ^C to stop), and
2) responsiveness (default 30 second timeout is too long)

The options I've come up with seem too kludgy -- there must be a 
simpler way. What I've thought of is:
a) swap out asyncore.loop for my own hacked version
b) push all of the orginal app into another thread, leaving the main 
thread for the GUI
c) have the threads raise an ExitNow exception based on a global flag.

(a) is the worst of it, as it's not robust across mods to asyncore. 
It'd be great if there was a separate asyncore.get_poll_func() as part 
of the API. Or an idle func that asyncore.loop would call on timeouts....

Any pointers to better/cleaner ideas welcomed.

Thanks,
--Hal




More information about the Medusa-dev mailing list