SHARE
TWEET

Untitled

a guest Jun 26th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. import subprocess
  3. import threading
  4. import time
  5.  
  6.  
  7. def run_busyproc():
  8.     print(f'{time.time()} Starting busyprocess...')
  9.     subprocess.run(["python", "busyprocess.py"])
  10.     print(f'{time.time()} busyprocess done.')
  11.  
  12.  
  13. if __name__ == "__main__":
  14.     thread = threading.Thread(target=run_busyproc)
  15.     print("Starting thread...")
  16.     thread.start()
  17.     while thread.is_alive():
  18.         print(f"{time.time()} Main thread doing its thing...")
  19.         time.sleep(0.5)
  20.     print("Thread is done (?)")
  21.     print("Exit main.")
  22.      
  23. #!/usr/bin/env python
  24. from time import sleep
  25.  
  26.  
  27. if __name__ == "__main__":
  28.     for _ in range(100):
  29.         print("Busy...")
  30.         sleep(0.5)
  31.     print("Done")
  32.      
  33. Starting thread...
  34. 1555970578.20475 Main thread doing its thing...
  35. 1555970578.204679 Starting busyprocess...
  36.  
  37. Busy...
  38. 1555970578.710308 Main thread doing its thing...
  39. Busy...
  40. 1555970579.2153869 Main thread doing its thing...
  41. Busy...
  42. 1555970579.718168 Main thread doing its thing...
  43. Busy...
  44. 1555970580.2231748 Main thread doing its thing...
  45. Busy...
  46. 1555970580.726122 Main thread doing its thing...
  47. Busy...
  48. 1555970628.009814 Main thread doing its thing...
  49.  
  50. Done
  51. 1555970628.512945 Main thread doing its thing...
  52.  
  53. 1555970628.518155 busyprocess done.
  54. Thread is done (?)
  55. Exit main.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top