After reading the PEP I realized it is much simpler. The test is for interrupts that occur at a low-level - and not for permission issues. The test is failing because there is a permission issue, not a missed interrupt issue. Modifying the code to: (see line 510)
+506 try:
+507 lock_func(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
+508 lock_func(f, fcntl.LOCK_UN)
+509 time.sleep(0.01)
+510 except (BlockingIOError, PermissionError):
+511 break
+512 # the child locked the file just a moment ago for 'sleep_time' seconds
+513 # that means that the lock below will block for 'sleep_time' minus some
+514 # potential context switch delay
+515 lock_func(f, fcntl.LOCK_EX)
+516 dt = time.monotonic() - start_time
+517 self.assertGreaterEqual(dt, self.sleep_time)
+518 self.stop_alarm()
fixes this. |