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

Function write_random_data

example_code/item_077.py:109–116  ·  view source on GitHub ↗
(path, write_count, interval)

Source from the content-addressed store, hash-verified

107from tempfile import TemporaryDirectory
108
109def write_random_data(path, write_count, interval):
110 with open(path, "wb") as f:
111 for i in range(write_count):
112 time.sleep(random.random() * interval)
113 letters = random.choices(string.ascii_lowercase, k=10)
114 data = f'{path}-{i:02}-{"".join(letters)}\n'
115 f.write(data.encode())
116 f.flush()
117
118def start_write_threads(directory, file_count):
119 paths = []

Callers

nothing calls this directly

Calls 2

openFunction · 0.85
writeMethod · 0.80

Tested by

no test coverage detected