Skip to content

Commit

Permalink
Adding a few extra commands to startbfs for convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
grf14003 committed Apr 1, 2020
1 parent 36f9d80 commit 79a4c3b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
1 change: 0 additions & 1 deletion bfs/include/DataSyncThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class DataSyncThread
void startComms();
bool isRunning();
bool stopComms();
bool isClientConnected() { return continueThread; };
unsigned int getSocketNumber() { return (unsigned int) socket; };
bool areIncomingAttributesAvailable();
vector<Attribute> getIncomingAttributes();
Expand Down
39 changes: 39 additions & 0 deletions bfs/scripts/log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,42 @@ Hello new client!
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
Hello new client!
Listening for clients...
Hello new client!
Listening for clients...
Hello new client!
Listening for clients...
Hello new client!
Listening for clients...
Hello new client!
Listening for clients...
Hello new client!
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
Listening for clients...
Hello new client!
Listening for clients...
27 changes: 21 additions & 6 deletions bfs/scripts/startbfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@
os.chdir(os.path.dirname(os.path.abspath(__file__)))


def start_program(program):
def start_program(program, pause=True):
if not isinstance(program, str):
raise ValueError("Argument passed to start_program_sync() should be a string")
command = "START /wait \"\" CMD /c \"\"" + program + "\"&pause\""
if pause:
command = "START /wait \"\" CMD /c \"\"" + program + "\"&pause\""
else:
command = "START /wait \"\" CMD /c \"" + program + "\""
print("> " + command)
return os.system(command)


def start_program_async(program):
def start_program_async(program, pause=True):
# 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.
print("\n======> Starting ASYNC: %s <======" % program)
p = mp.Process(target=start_program, args=(program,))
p = mp.Process(target=start_program, args=(program,pause))
p.start()
print(p.pid)
return p


Expand Down Expand Up @@ -66,6 +70,8 @@ def main():
will read and adjust their settings accordingly. That way, each process only has access to their own config settings.
Note: this can be used in conjunction with -a and -p, but care is necessary to not produce any duplicate proceses.""")
parser.add_argument("-b", "--build", help="If specified, run buildbfs.py before proceeding.", action="store_true")
parser.add_argument("-t", "--terminal", help="If specified, run a prompt while waiting for the processes to finish execution", action="store_true")
parser.add_argument("-s", "--stop", help="If specified, keep the cmd windows for the aglo and procs open with a 'pause' prompt after they are finished executing", action="store_true")
args = parser.parse_args()

if args.build:
Expand All @@ -75,8 +81,17 @@ def main():
binary_path = os.path.abspath("..\\bin")
exe_ending = ".exe"
exe_names = get_exe_names(args.algorithm, args.io_processor, args.config)
procs = [start_program_async(os.path.join(binary_path, x) + exe_ending) for x in exe_names]

procs = [start_program_async(os.path.join(binary_path, x) + exe_ending, pause=args.stop) for x in exe_names]

if args.console:
print("Press t to terminate or h for help.")
loop = True
while loop:
user_in = input()
if user_in == "t":
loop = False

print("Waiting for cmd windows to close...")
[proc.join() for proc in procs]

print("DONE")
Expand Down

0 comments on commit 79a4c3b

Please sign in to comment.