Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. import os
  2. import threading
  3. import subprocess
  4.  
  5. class subprocess_thread(threading.Thread):
  6.  
  7.     def __init__(self, filename):
  8.         threading.Thread.__init__(self)
  9.         self.filename = filename
  10.  
  11.     def run(self):
  12.         FNULL = open(os.devnull, 'w')
  13.         cmd = subprocess.Popen(['python {0} &'.format(self.filename)], shell=True)
  14.         cmd.communicate()
  15.         try:
  16.             cmd.kill()
  17.         except OSError:
  18.             pass
  19.  
  20.  
  21. script_thread = subprocess_thread(os.path.join(os.path.dirname(os.path.abspath(__file__)), "test.py"))
  22. script_thread.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement