(self)
| 224 | @unittest.skipUnless(threading, 'Threading required for this test.') |
| 225 | @threading_helper.reap_threads |
| 226 | def test_poll_blocks_with_negative_ms(self): |
| 227 | for timeout_ms in [None, -1000, -1, -1.0, -0.1, -1e-100]: |
| 228 | # Create two file descriptors. This will be used to unlock |
| 229 | # the blocking call to poll.poll inside the thread |
| 230 | r, w = os.pipe() |
| 231 | pollster = select.poll() |
| 232 | pollster.register(r, select.POLLIN) |
| 233 | |
| 234 | poll_thread = threading.Thread(target=pollster.poll, args=(timeout_ms,)) |
| 235 | poll_thread.start() |
| 236 | poll_thread.join(timeout=0.1) |
| 237 | self.assertTrue(poll_thread.is_alive()) |
| 238 | |
| 239 | # Write to the pipe so pollster.poll unblocks and the thread ends. |
| 240 | os.write(w, b'spam') |
| 241 | poll_thread.join() |
| 242 | self.assertFalse(poll_thread.is_alive()) |
| 243 | os.close(r) |
| 244 | os.close(w) |
| 245 | |
| 246 | |
| 247 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected