Any other Python flaws?

Oleg Broytmann phd at phd.fep.ru
Sun Jun 17 05:23:48 EDT 2001


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

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.)

Oleg.
----
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list