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

Function run_threads

example_code/item_077.py:82–98  ·  view source on GitHub ↗
(handles, interval, output_path)

Source from the content-addressed store, hash-verified

80from threading import Lock, Thread
81
82def run_threads(handles, interval, output_path):
83 with open(output_path, "wb") as output:
84 lock = Lock()
85
86 def write(data):
87 with lock:
88 output.write(data)
89
90 threads = []
91 for handle in handles:
92 args = (handle, interval, write)
93 thread = Thread(target=tail_file, args=args)
94 thread.start()
95 threads.append(thread)
96
97 for thread in threads:
98 thread.join()
99
100
101print("Example 4")

Callers 1

item_077.pyFile · 0.85

Calls 2

openFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected