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

Function execute

example_code/item_052.py:109–119  ·  view source on GitHub ↗
(workers)

Source from the content-addressed store, hash-verified

107from threading import Thread
108
109def execute(workers):
110 threads = [Thread(target=w.map) for w in workers]
111 for thread in threads:
112 thread.start()
113 for thread in threads:
114 thread.join()
115
116 first, *rest = workers
117 for worker in rest:
118 first.reduce(worker)
119 return first.result
120
121
122print("Example 8")

Callers 1

mapreduceFunction · 0.85

Calls 1

reduceMethod · 0.45

Tested by

no test coverage detected