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

Method _shutdown_get

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

Source from the content-addressed store, hash-verified

470 return self._join(q, results, True)
471
472 def _shutdown_get(self, immediate):
473 q = self.type2test(2)
474 results = []
475 go = threading.Event()
476 q.put("Y")
477 q.put("D")
478 # queue full
479
480 if immediate:
481 thrds = (
482 (self._get_shutdown, (q, go, results)),
483 (self._get_shutdown, (q, go, results)),
484 )
485 else:
486 thrds = (
487 # on shutdown(immediate=False)
488 # one of these threads should raise Shutdown
489 (self._get, (q, go, results)),
490 (self._get, (q, go, results)),
491 (self._get, (q, go, results)),
492 )
493 threads = []
494 for func, params in thrds:
495 threads.append(threading.Thread(target=func, args=params))
496 threads[-1].start()
497 q.shutdown(immediate)
498 go.set()
499 for t in threads:
500 t.join()
501 if immediate:
502 self.assertListEqual(results, [True, True])
503 else:
504 self.assertListEqual(sorted(results), [False] + [True]*(len(thrds)-1))
505
506 def test_shutdown_get(self):
507 return self._shutdown_get(False)

Callers 2

test_shutdown_getMethod · 0.95

Calls 11

setMethod · 0.95
sortedFunction · 0.85
lenFunction · 0.85
type2testMethod · 0.80
EventMethod · 0.80
assertListEqualMethod · 0.80
putMethod · 0.45
appendMethod · 0.45
startMethod · 0.45
shutdownMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected