diff options
author | Christos Zoulas <christos@zoulas.com> | 2021-09-09 17:50:58 +0000 |
---|---|---|
committer | Christos Zoulas <christos@zoulas.com> | 2021-09-09 17:50:58 +0000 |
commit | 48e53e1c7c23f855d76ddb37a01c1ab578aa2a26 (patch) | |
tree | 616c7e1ab6bfaee05ec07c5d1ee30b0a48331154 /python | |
parent | c8deb32eab1089d1841482fb2e91833f114b6712 (diff) | |
download | file-git-48e53e1c7c23f855d76ddb37a01c1ab578aa2a26.tar.gz |
Add threads test from PR/285
Diffstat (limited to 'python')
-rw-r--r-- | python/threads.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/python/threads.py b/python/threads.py new file mode 100644 index 00000000..5be1e360 --- /dev/null +++ b/python/threads.py @@ -0,0 +1,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() |