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

Class _TriggerThread

Lib/test/test_queue.py:26–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25# A thread to run a function that unclogs a blocked Queue.
26class _TriggerThread(threading.Thread):
27 def __init__(self, fn, args):
28 self.fn = fn
29 self.args = args
30 self.startedEvent = threading.Event()
31 threading.Thread.__init__(self)
32
33 def run(self):
34 # The sleep isn't necessary, but is intended to give the blocking
35 # function in the main thread a chance at actually blocking before
36 # we unclog it. But if the sleep is longer than the timeout-based
37 # tests wait in their blocking functions, those tests will fail.
38 # So we give them much longer timeout values compared to the
39 # sleep here (I aimed at 10 seconds for blocking functions --
40 # they should never actually wait that long - they should make
41 # progress as soon as we call self.fn()).
42 time.sleep(0.1)
43 self.startedEvent.set()
44 self.fn(*self.args)
45
46
47# Execute a function that blocks, and in a separate thread, a function that

Callers 2

do_blocking_testMethod · 0.85

Calls

no outgoing calls

Tested by 2

do_blocking_testMethod · 0.68