Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import subprocess
- import threading
- import time
- def run_busyproc():
- print(f'{time.time()} Starting busyprocess...')
- subprocess.run(["python", "busyprocess.py"])
- print(f'{time.time()} busyprocess done.')
- if __name__ == "__main__":
- thread = threading.Thread(target=run_busyproc)
- print("Starting thread...")
- thread.start()
- while thread.is_alive():
- print(f"{time.time()} Main thread doing its thing...")
- time.sleep(0.5)
- print("Thread is done (?)")
- print("Exit main.")
- #!/usr/bin/env python
- from time import sleep
- if __name__ == "__main__":
- for _ in range(100):
- print("Busy...")
- sleep(0.5)
- print("Done")
- Starting thread...
- 1555970578.20475 Main thread doing its thing...
- 1555970578.204679 Starting busyprocess...
- Busy...
- 1555970578.710308 Main thread doing its thing...
- Busy...
- 1555970579.2153869 Main thread doing its thing...
- Busy...
- 1555970579.718168 Main thread doing its thing...
- Busy...
- 1555970580.2231748 Main thread doing its thing...
- Busy...
- 1555970580.726122 Main thread doing its thing...
- Busy...
- 1555970628.009814 Main thread doing its thing...
- Done
- 1555970628.512945 Main thread doing its thing...
- 1555970628.518155 busyprocess done.
- Thread is done (?)
- Exit main.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement