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

Function start_write_threads

example_code/item_077.py:118–130  ·  view source on GitHub ↗
(directory, file_count)

Source from the content-addressed store, hash-verified

116 f.flush()
117
118def start_write_threads(directory, file_count):
119 paths = []
120 for i in range(file_count):
121 path = os.path.join(directory, str(i))
122 with open(path, "w"):
123 # Make sure the file at this path will exist when
124 # the reading thread tries to poll it.
125 pass
126 paths.append(path)
127 args = (path, 10, 0.1)
128 thread = Thread(target=write_random_data, args=args)
129 thread.start()
130 return paths
131
132def close_all(handles):
133 time.sleep(1)

Callers 1

setupFunction · 0.70

Calls 2

openFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected