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

Method _shutdown_put_join

Lib/test/test_queue.py:576–607  ·  view source on GitHub ↗
(self, immediate)

Source from the content-addressed store, hash-verified

574 return self._shutdown_join(False)
575
576 def _shutdown_put_join(self, immediate):
577 q = self.type2test(2)
578 results = []
579 go = threading.Event()
580 q.put("Y")
581 # queue not fulled
582
583 thrds = (
584 (self._put_shutdown, (q, "E", go, results)),
585 (self._join, (q, results)),
586 )
587 threads = []
588 for func, params in thrds:
589 threads.append(threading.Thread(target=func, args=params))
590 threads[-1].start()
591 self.assertEqual(q.unfinished_tasks, 1)
592
593 q.shutdown(immediate)
594 go.set()
595
596 if immediate:
597 with self.assertRaises(self.queue.ShutDown):
598 q.get_nowait()
599 else:
600 result = q.get()
601 self.assertEqual(result, "Y")
602 q.task_done()
603
604 for t in threads:
605 t.join()
606
607 self.assertEqual(results, [True]*len(thrds))
608
609 def test_shutdown_immediate_put_join(self):
610 return self._shutdown_put_join(True)

Callers 2

Calls 13

setMethod · 0.95
type2testMethod · 0.80
EventMethod · 0.80
putMethod · 0.45
appendMethod · 0.45
startMethod · 0.45
assertEqualMethod · 0.45
shutdownMethod · 0.45
assertRaisesMethod · 0.45
get_nowaitMethod · 0.45
getMethod · 0.45
task_doneMethod · 0.45

Tested by

no test coverage detected