Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import subprocess
  2. import threading
  3. import logging
  4. import os
  5. import time
  6.  
  7. logging.basicConfig(level=logging.DEBUG, format='[%(levelname)s] (%(threadName)-5s) %(message)s')
  8.  
  9. threads = {}
  10. mountpoints = ["mp_" + str(x) for x in range(30)]
  11.  
  12. def worker(mountpoint: str):
  13. path = os.path.join(mountpoint, "f_" + mountpoint)
  14. logging.debug("writing to {}".format(path))
  15. with open(path, "w") as f:
  16. for x in range(10):
  17. time.sleep(0.05) # 50 miliseconds
  18. f.write(str(time.time()) + '\n')
  19.  
  20.  
  21. for d in mountpoints:
  22. os.mkdir(d)
  23. subprocess.check_call("mount -t cifs -o username=user,domain=domain.local,password=password //server/share$ {}".format(d), shell=True)
  24. t = threading.Thread(name=d, target=worker, kwargs={"mountpoint":d})
  25. t.daemon = True
  26. t.start()
  27. threads[d] = t
  28.  
  29. for d,t in threads.items():
  30. t.join()
  31. subprocess.check_call("umount {}".format(d), shell=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement