MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_poll_blocks_with_negative_ms

Method test_poll_blocks_with_negative_ms

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

Source from the content-addressed store, hash-verified

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
235if __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