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