On Fri, 2005-09-30 at 18:33 +0200, Antoine Pitrou wrote:
> Hi Jp,
> 
> Le vendredi 30 septembre 2005 à 12:20 -0400, Jp Calderone a écrit :
> > "Advocating" might be putting it too strongly :)  "Experimenting with"
> > describes the current state of things most accurately.
> 
> Ok :)
> 
> > The problem it aims to solve is integration with cooperative threading
> > systems which don't work very well.  An example of such a loop is the
> > wx event loop.  
> > 
> > Whenever a modal dialog is displayed or a menu is activated, wx's loop
> > stops cooerating.

  That is wx's problem.  Try PyGTK some day; I hear it's really
good! ;-)

> 
> This specific problem hides the more general problem, which is that GUI
> and network activities have different typical latencies. As I explained
> on the twisted ML, a GUI needs very good response times to feel friendly
> (typically below 20 or even 10 ms.), whereas some network protocols have
> non-trivial calculations which can go above 100 ms.

  With PyGTK a typical solution for this is to use a generator function
executing an "idle function", which would make the non-trivial
calculations, but yield control back to the main loop periodically, in
order to process GUI events. For example, see the last code block in
http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq23.020.htp

>  Moreover, you don't
> want a sudden flood of network events to block events in the GUI.

  Process one event at a time, after each event give back control to the
main loop, and give low priority to socket IO events.  Problem solved.

> 
> This is why even without considering wx's specificities, it is still
> useful to keep GUI and network activities in separate threads.

  You are considering a scenario that seldom happens to design a
solution that is far too complicated for most cases.

  Regards.

-- 
Gustavo J. A. M. Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
The universe is always one step beyond logic

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to