[Python-Dev] RFC: PEP 475, Retry system calls failing with EINTR

Antoine Pitrou solipsis at pitrou.net
Tue Sep 2 16:48:00 CEST 2014


On Mon, 1 Sep 2014 21:17:33 +0000 (UTC)
Matthew Woodcraft <matthew at woodcraft.me.uk> wrote:
> 
> > If such applications exist, they are not portable and are subject to
> > race conditions (deadlock if the signal comes before the system call).
> 
> The program is certainly not portable (which is not any kind of a
> problem), and as pselect is unavailable there is indeed the usual
> theoretical race (which has not been a problem in practice in the ten
> years it's been running).
> 
> (The program handles SIGTERM so that it can do a bit of cleanup before
> exiting, and it uses the signal-handler-sets-a-flag technique. The call
> that might be interrupted is sleep(), so the program doesn't strictly
> _rely_ on the existing behaviour; it would just become very slow to
> exit.)

So, if it's just for process exit, just let the signal handler raise an
exception and catch the exception at the top-level.

Regards

Antoine.




More information about the Python-Dev mailing list