Charles-François Natali added the comment:
> Thanks!
You're welcome :)
BTW, I don't know if that would fulfill the goal of your test here,
but when I want to check for EINTR handling, I just use alarm (see
attached patch). The only downside is that the minimum delay is 1
second.
----------
keywords: +patch
Added file: http://bugs.python.org/file31496/eintr_alarm.diff
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18786>
_______________________________________
--- cpython-df2fdd42b375/Lib/test/_test_multiprocessing.py 2013-08-26
20:28:21.000000000 +0000
+++ cpython/Lib/test/_test_multiprocessing.py 2013-08-28 13:51:02.000000000
+0000
@@ -2923,29 +2923,21 @@
ALLOWED_TYPES = ('processes',)
- @classmethod
- def _killer(cls, pid):
- time.sleep(0.5)
- os.kill(pid, signal.SIGUSR1)
-
- @unittest.skipUnless(hasattr(signal, 'SIGUSR1'), 'requires SIGUSR1')
+ @unittest.skipUnless(hasattr(signal, 'alarm'), 'requires signal.alarm')
def test_poll_eintr(self):
got_signal = [False]
def record(*args):
got_signal[0] = True
pid = os.getpid()
- oldhandler = signal.signal(signal.SIGUSR1, record)
- try:
- killer = self.Process(target=self._killer, args=(pid,))
- killer.start()
- p = self.Process(target=time.sleep, args=(1,))
- p.start()
- p.join()
- self.assertTrue(got_signal[0])
- self.assertEqual(p.exitcode, 0)
- killer.join()
- finally:
- signal.signal(signal.SIGUSR1, oldhandler)
+ oldhandler = signal.signal(signal.SIGALRM, record)
+ self.addCleanup(signal.signal, signal.SIGALRM, oldhandler)
+ self.addCleanup(signal.alarm, 0)
+ signal.alarm(1)
+ p = self.Process(target=time.sleep, args=(2,))
+ p.start()
+ p.join()
+ self.assertTrue(got_signal[0])
+ self.assertEqual(p.exitcode, 0)
#
# Test to verify handle verification, see issue 3321
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com