[Python-checkins] r87293 - python/branches/py3k/Lib/test/test_threadsignals.py

antoine.pitrou python-checkins at python.org
Thu Dec 16 00:38:50 CET 2010


Author: antoine.pitrou
Date: Thu Dec 16 00:38:50 2010
New Revision: 87293
Log:
Make test_threadsignals more lax, and add notes
Modified:
 python/branches/py3k/Lib/test/test_threadsignals.py
Modified: python/branches/py3k/Lib/test/test_threadsignals.py
==============================================================================
--- python/branches/py3k/Lib/test/test_threadsignals.py	(original)
+++ python/branches/py3k/Lib/test/test_threadsignals.py	Thu Dec 16 00:38:50 2010
@@ -142,6 +142,9 @@
 # receive a signal. Check this by repeatedly interrupting a lock
 # acquire in the main thread, and make sure that the lock acquire times
 # out after the right amount of time.
+ # NOTE: this test only behaves as expected if C signals get delivered
+ # to the main thread. Otherwise lock.acquire() itself doesn't get
+ # interrupted and the test trivially succeeds.
 self.start = None
 self.end = None
 self.sigs_recvd = 0
@@ -159,7 +162,7 @@
 self.end = time.time()
 def send_signals():
 for _ in range(40):
- time.sleep(0.05)
+ time.sleep(0.02)
 os.kill(process_pid, signal.SIGUSR1)
 done.release()
 
@@ -172,7 +175,9 @@
 # This allows for some timing and scheduling imprecision
 self.assertLess(self.end - self.start, 2.0)
 self.assertGreater(self.end - self.start, 0.3)
- self.assertEqual(40, self.sigs_recvd)
+ # If the signal is received several times before PyErr_CheckSignals()
+ # is called, the handler will get called less than 40 times.
+ self.assertGreater(self.sigs_recvd, 20)
 finally:
 signal.signal(signal.SIGUSR1, old_handler)
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /