Processes items in a queue.
(input_queue, output_queue, worker, stop_event)
| 26 | |
| 27 | |
| 28 | def process_from_queue(input_queue, output_queue, worker, stop_event): |
| 29 | """Processes items in a queue.""" |
| 30 | while not stop_event.is_set(): |
| 31 | try: |
| 32 | # Keep trying to get an item. |
| 33 | x = input_queue.get(timeout=0.05) |
| 34 | except queue.Empty: |
| 35 | continue |
| 36 | |
| 37 | # Do actual work. |
| 38 | y = worker(x) |
| 39 | |
| 40 | while not stop_event.is_set(): |
| 41 | try: |
| 42 | # Keep trying to push the item. |
| 43 | output_queue.put(y, timeout=0.05) |
| 44 | break |
| 45 | except queue.Full: |
| 46 | pass |
| 47 | |
| 48 | |
| 49 | def submit_generator_to_queue(input_queue, generator_fn, generator_kwargs, |
nothing calls this directly
no test coverage detected
searching dependent graphs…