[Python-Dev] Signal-resistant code (was: Two random and nearly unrelated ideas)

Oren Tirosh oren-py-d@hishome.net
Wed, 4 Sep 2002 08:46:46 -0400

On Wed, Sep 04, 2002 at 07:44:32AM -0400, Guido van Rossum wrote:
> > > Second (also considered during the above edit), it would be nice to get rid
> > > of the ticker altogether in systems with proper signal support.  On those
> > > platforms couldn't an alarm replace polling for the ticker?  
> > 
> > Not before all all Python I/O calls are converted to be EINTR-safe.
> > 
> > After running into some problems with I/O interrupted by signals I tried to
> > fix it myself but it requires a lot of work in some of the hairiest places 
> > in the Python codebase.
> Signals: just say no.  It is impossible to write correct code in the
> presence of signals.

Wrapping all I/O calls with PyOS_ wrappers would be a good start. After
that the wrappers can be modified to retry the call on EINTR. This should 
solve all the problems I have encountered with interference to Python code 
by signals. Any other problems I should be aware of?