Advertisement
Guest User

Untitled

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