Created
December 29, 2016 16:02
-
-
Save tatic0/51012c9edb66742ee1435ea6f4b9e9a7 to your computer and use it in GitHub Desktop.
Python thread + subprocess example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# it will calculate the md5sum of | |
# all files in the arborescence | |
from threading import Thread | |
import subprocess | |
import os | |
def slowthing(i): | |
cmd = ["md5sum", i] | |
print(cmd) | |
subprocess.call(cmd) | |
for i,j,k in os.walk("."): | |
for l in k: | |
each = os.path.join(i,l) | |
t = Thread(target=slowthing, args=(each,)) | |
t.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment