Skip to content

Instantly share code, notes, and snippets.

@jtrain
Created January 9, 2014 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtrain/8344157 to your computer and use it in GitHub Desktop.
Save jtrain/8344157 to your computer and use it in GitHub Desktop.
Spawn a long-lived process outside of PSS/E
"""
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()
"""
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