Skip to content

Commit

Permalink
Adding async start program function to startbfs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
grf14003 committed Jan 28, 2020
1 parent 7853c71 commit 3595c6f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions breadcrumbs/scripts/startbfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
import subprocess


def start_program(command):
cmd_list = command.split(" ")
return subprocess.call(cmd_list)
def start_program(program):
if not isinstance(program, str):
raise ValueError("Argument passed to start_program_sync() should be a string")
return os.system("cmd /c " + program)


def start_program_no_hang(command):
print("Running %s from cwd %s" % (command, os.getcwd()))
proc = mp.Process(target=start_program, args=(command,))
proc.start()
return proc
def start_program_async(program):
# TODO: This needs to account for the number of cores...
# Add another function called start_programs_async that takes a list
# of programs and starts them on the proper cores.
p = mp.Process(target=start_program, args=(program,))
p.start()
return p


def main():
os.system("cmd /c ..\\bin\\Breadcrumbs.exe")
p = start_program_async("..\\bin\\Breadcrumbs.exe")
p.join()
print("DONE")


Expand Down

0 comments on commit 3595c6f

Please sign in to comment.