[Urwid] Twisted version of generic_main_loop

Ian Ward ian at excess.org
Wed Aug 27 14:58:38 EDT 2008


Walter Mundt wrote:
> Ian Ward wrote:
>> It's a good start.  I was hoping this could be done with
>> get_input_descriptors[1] and get_input_nonblocking[2] instead of using
>> threads.
>>
>> [1] http://excess.org/urwid/reference.html#Screen-get_input_descriptors
>> [2] http://excess.org/urwid/reference.html#Screen-get_input_nonblocking
> 
> Done.  Also, this version adds a handle_reactor parameter.  If False, 
> rather than looping the function simply returns a twisted Deferred that 
> will trigger when the UI shuts down, whether via an ExitMainLoop call 
> (callback True) or a different unhandled exception in one of the 
> handlers passed in (errback).

Great!  That was fast, Walter :-)

A couple final suggestions: twisted_main_loop needs a docstring 
explaining what you said above, and the code should be written in a way 
that I can add it to main_loop.py even on systems without twisted 
installed - either only import twisted.(...) inside the functions that 
need those symbols, or handle the ImportError and make twisted_main_loop 
send a helpful error message.

Ian




More information about the Urwid mailing list