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

Function start_write_threads

example_code/item_078.py:200–212  ·  view source on GitHub ↗
(directory, file_count)

Source from the content-addressed store, hash-verified

198 f.flush()
199
200def start_write_threads(directory, file_count):
201 paths = []
202 for i in range(file_count):
203 path = os.path.join(directory, str(i))
204 with open(path, "w"):
205 # Make sure the file at this path will exist when
206 # the reading thread tries to poll it.
207 pass
208 paths.append(path)
209 args = (path, 10, 0.1)
210 thread = Thread(target=write_random_data, args=args)
211 thread.start()
212 return paths
213
214def close_all(handles):
215 time.sleep(1)

Callers 1

setupFunction · 0.70

Calls 2

openFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected