(really) simple thread example in python

# 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()

you can clone/download here:
https://gist.github.com/tatic0/51012c9edb66742ee1435ea6f4b9e9a7

Leave a Reply

Your email address will not be published. Required fields are marked *