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

Function simulate_pool

example_code/item_074.py:138–151  ·  view source on GitHub ↗
(pool, grid)

Source from the content-addressed store, hash-verified

136from concurrent.futures import ThreadPoolExecutor
137
138def simulate_pool(pool, grid):
139 next_grid = LockingGrid(grid.height, grid.width)
140
141 futures = []
142 for y in range(grid.height):
143 for x in range(grid.width):
144 args = (y, x, grid.get, next_grid.set)
145 future = pool.submit(step_cell, *args) # Fan-out
146 futures.append(future)
147
148 for future in futures:
149 future.result() # Fan-in
150
151 return next_grid
152
153
154print("Example 3")

Callers 1

item_074.pyFile · 0.85

Calls 2

LockingGridClass · 0.70
appendMethod · 0.45

Tested by

no test coverage detected