Any other Python flaws?

Mitch Chapman mitch.chapman at bioreason.com
Mon Jun 18 12:05:43 EDT 2001


Oleg Broytmann wrote:
> 
> On Sat, 16 Jun 2001, Mitch Chapman wrote:
> > > while not self._cancel:
> > >     do_more_computation()
> >
> > Yep, this is a common approach.  See Xt work procedures,
> > Gtk+ idle tasks, or even guides to programming in Oberon.
> > Unfortunately, this method doesn't work very well when your
> > background thread needs to do blocking operations, e.g. reading
> > from a socket.
> 
>    But you cannot safely interrupt such a blocking thread because:
> 
> 1. It is VERY OS-dependent, and

The fact that the implementation is OS-dependent does not 
imply that you cannot do it safely.  Can you say more about the
differences in semantics among the operating systems for
which Python supports threads?

> 2. Even on an OS that allows killing blocked threads you are guaranteed to
> have problems due to insufficient cleanup. If you need to kill blocking
> process make it real forked process. Or use non-blocking approach
> (non-blocking sockets, e.g.)

All of this tends to reinforce Andrew Kuchling's opinion that
threads were "a mistake".  I'm still unsure whether he meant
threads in general were a mistake or whether he meant that 
platform-independent threads facilities should be augmented with 
platform-specific facilities.

-- 
Mitch Chapman
Mitch.Chapman at bioreason.com




More information about the Python-list mailing list