blob: 5be1e360b8b0aa5061e6942337de7b84ba37edb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# Threads test
import threading
import magic
MAX_BYTES = 4096
def thread_function():
with open("/tmp/foo.csv", "rb") as bytes_file:
print(magic.detect_from_content(
bytes_file.read(MAX_BYTES)
).encoding)
if __name__ == '__main__':
threads = list()
for index in range(3):
thread = threading.Thread(target=thread_function)
threads.append(thread)
thread.start()
for index, thread in enumerate(threads):
thread.join()
|