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