Created
January 9, 2014 23:31
-
-
Save jtrain/8344157 to your computer and use it in GitHub Desktop.
Spawn a long-lived process outside of PSS/E
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Child thread | |
constantly writes to a file for 60 seconds | |
""" | |
from __future__ import with_statement | |
import time | |
FILE = 'demo.txt' | |
def child(): | |
print 'running child' | |
with open(FILE, 'w') as demo: | |
demo.write('BEGIN\n') | |
for i in range(60): | |
time.sleep(1) | |
with open(FILE, 'a') as demo: | |
demo.write('%d\n' % time.time()) | |
child() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Main thread | |
Spawns a new process outside of itself. | |
""" | |
import subprocess | |
from tkFileDialog import askopenfilename | |
def main(): | |
childscript = askopenfilename(title="Run which script?") | |
subprocess.Popen( | |
["python", childscript], | |
creationflags=subprocess.CREATE_NEW_CONSOLE) | |
print "finished main" | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment