Problem in threading

Mike Meyer mwm at mired.org
Wed Dec 29 19:43:26 CET 2004


Duncan Booth <duncan.booth at invalid.invalid> writes:

> That leaves the former case: if your task has to stop and wait for
> something else to happen (e.g. data to be read from a network, or to
> be read from a disc file), then splitting it into multiple threads
> may allow the waits to be overlapped with useful processing which
> could result in an overall decrease in processing time.

If you're on a Unix-like system, you'll use less aspirin if you do
this kind of thing with async I/O and the select module. If you're on
Windows, the restrictions on what you can select on make it much less
useful. Python's threading models is pretty primitive. You get the C
model (which is error-prone), the Java model (in 2.4, and also
error-prone), or Queues. Queues aren't error-prone, but result in the
same kind of behavior as you get with select: start I/O, do computing
while I/O is going on, block until I/O is complete.

      <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list