File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,28 @@ def test_threaded_poll(self):
205205 os .write (w , b'spam' )
206206 t .join ()
207207
208+ @unittest .skipUnless (threading , 'Threading required for this test.' )
209+ @reap_threads
210+ def test_poll_blocks_with_negative_ms (self ):
211+ for timeout_ms in [None , - 1 , - 1.0 ]:
212+ # Create two file descriptors. This will be used to unlock
213+ # the blocking call to poll.poll inside the thread
214+ r , w = os .pipe ()
215+ pollster = select .poll ()
216+ pollster .register (r , select .POLLIN )
217+
218+ poll_thread = threading .Thread (target = pollster .poll , args = (timeout_ms ,))
219+ poll_thread .start ()
220+ poll_thread .join (timeout = 0.1 )
221+ self .assertTrue (poll_thread .is_alive ())
222+
223+ # Write to the pipe so pollster.poll unblocks and the thread ends.
224+ os .write (w , b'spam' )
225+ poll_thread .join ()
226+ self .assertFalse (poll_thread .is_alive ())
227+ os .close (r )
228+ os .close (w )
229+
208230
209231def test_main ():
210232 run_unittest (PollTests )
You can’t perform that action at this time.
0 commit comments