From fc7fe4675470e4b6bb7dcdad4758dd4230d79bc4 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Mon, 30 Jun 2014 19:07:40 +0100 Subject: [PATCH] Add signal.siginterrupt to restart interrupted system calls --- pyinstrument/profiler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyinstrument/profiler.py b/pyinstrument/profiler.py index 17232f46..0af0d1b9 100644 --- a/pyinstrument/profiler.py +++ b/pyinstrument/profiler.py @@ -42,6 +42,10 @@ def start(self): if self.use_signal: try: signal.signal(signal.SIGALRM, self._signal) + # the following tells the system to restart interrupted system calls if they are + # interrupted before any data has been transferred. This avoids many of the problems + # related to signals interrupting system calls, see issue #16 + signal.siginterrupt(signal.SIGALRM, False) except ValueError: raise NotMainThreadError()