MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / StoppableWorker

Class StoppableWorker

example_code/item_073.py:63–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62
63class StoppableWorker(Thread):
64 def __init__(self, func, in_queue, out_queue, *args, **kwargs):
65 super().__init__(*args, **kwargs)
66 self.func = func
67 self.in_queue = in_queue
68 self.out_queue = out_queue
69
70 def run(self):
71 while True:
72 try:
73 item = self.in_queue.get()
74 except ShutDown:
75 return
76 else:
77 result = self.func(item)
78 self.out_queue.put(result)
79 self.in_queue.task_done()
80
81
82def game_logic(state, neighbors):

Callers 1

item_073.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected