MCPcopy Create free account
hub / github.com/google-research/language / process_from_queue

Function process_from_queue

language/realm/parallel.py:28–46  ·  view source on GitHub ↗

Processes items in a queue.

(input_queue, output_queue, worker, stop_event)

Source from the content-addressed store, hash-verified

26
27
28def 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
49def submit_generator_to_queue(input_queue, generator_fn, generator_kwargs,

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…