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

Function write_random_data

example_code/item_078.py:191–198  ·  view source on GitHub ↗
(path, write_count, interval)

Source from the content-addressed store, hash-verified

189from tempfile import TemporaryDirectory
190
191def write_random_data(path, write_count, interval):
192 with open(path, "wb") as f:
193 for i in range(write_count):
194 time.sleep(random.random() * interval)
195 letters = random.choices(string.ascii_lowercase, k=10)
196 data = f'{path}-{i:02}-{"".join(letters)}\n'
197 f.write(data.encode())
198 f.flush()
199
200def start_write_threads(directory, file_count):
201 paths = []

Callers

nothing calls this directly

Calls 2

openFunction · 0.85
writeMethod · 0.80

Tested by

no test coverage detected