MCPcopy Index your code
hub / github.com/python/cpython / test_poll_blocks_with_negative_ms

Method test_poll_blocks_with_negative_ms

Lib/test/test_poll.py:226–244  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
247if __name__ == '__main__':

Callers

nothing calls this directly

Calls 10

startMethod · 0.95
joinMethod · 0.95
is_aliveMethod · 0.95
assertTrueMethod · 0.80
assertFalseMethod · 0.80
pipeMethod · 0.45
pollMethod · 0.45
registerMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected