wxPython and threads

Nick Craig-Wood nick at craig-wood.com
Thu Jul 19 13:30:04 CEST 2007


Josiah Carlson <josiah.carlson at sbcglobal.net> wrote:
>  Sending results one at a time to the GUI is going to be slow for any 
>  reasonably fast search engine (I've got a pure Python engine that does 
>  50k results/second without breaking a sweat).  Don't do that.  Instead, 
>  have your search thread create a list, which it fills with items for 
>  some amount of time, *then* sends it off to the GUI thread (creating a 
>  new list that it then fills, etc.).  While you *could* use a Queue, it 
>  is overkill for what you want to do (queues are really only useful when 
>  there is actual contention for a resource and you want to block when a 
>  resource is not available).

I'd dispute that.  If you are communicating between threads use a
Queue and you will save yourself thread heartache.  Queue has a non
blocking read interface Queue.get_nowait().

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list