Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import threading
- import subprocess
- class subprocess_thread(threading.Thread):
- def __init__(self, filename):
- threading.Thread.__init__(self)
- self.filename = filename
- def run(self):
- FNULL = open(os.devnull, 'w')
- cmd = subprocess.Popen(['python {0} &'.format(self.filename)], shell=True)
- cmd.communicate()
- try:
- cmd.kill()
- except OSError:
- pass
- script_thread = subprocess_thread(os.path.join(os.path.dirname(os.path.abspath(__file__)), "test.py"))
- script_thread.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement