def compile_multishot_async(labscript_file, run_files, stream_port, done_callback): """Compiles labscript_file with run_files. This function is designed to be called in a thread. The stdout and stderr from the compilation will be shoveled into stream_port via zmq push as it spews forth, and when each compilation is complete, done_callback will be called with a boolean argument indicating success. Compilation will stop after the first failure.""" compiler_path = os.path.join(os.path.dirname(__file__), 'batch_compiler.py') to_child, from_child, child = zprocess.subprocess_with_queues( compiler_path, stream_port) try: for run_file in run_files: to_child.put(['compile', [labscript_file, run_file]]) while True: signal, data = from_child.get() if signal == 'done': success = data done_callback(data) break if not success: break except Exception: error = traceback.format_exc() zprocess.zmq_push_multipart(stream_port, data=['stderr', error]) to_child.put(['quit', None]) child.communicate() raise to_child.put(['quit', None]) child.communicate()
def compile_multishot_async(labscript_file, run_files, stream_port, done_callback): """Compiles labscript_file with run_files. This function is designed to be called in a thread. The stdout and stderr from the compilation will be shoveled into stream_port via zmq push as it spews forth, and when each compilation is complete, done_callback will be called with a boolean argument indicating success. Compilation will stop after the first failure.""" compiler_path = os.path.join(os.path.dirname(__file__), 'batch_compiler.py') to_child, from_child, child = zprocess.subprocess_with_queues(compiler_path, stream_port) try: for run_file in run_files: to_child.put(['compile', [labscript_file, run_file]]) while True: signal, data = from_child.get() if signal == 'done': success = data done_callback(data) break if not success: break except Exception: error = traceback.format_exc() zprocess.zmq_push_multipart(stream_port, data=['stderr', error]) to_child.put(['quit', None]) child.communicate() raise to_child.put(['quit', None]) child.communicate()
def compile_labscript_async(labscript_file, run_file, stream_port, done_callback): """Compiles labscript_file with run_file. This function is designed to be called in a thread. The stdout and stderr from the compilation will be shoveled into stream_port via zmq push as it spews forth, and when compilation is complete, done_callback will be called with a boolean argument indicating success.""" compiler_path = os.path.join(os.path.dirname(__file__), 'batch_compiler.py') to_child, from_child, child = zprocess.subprocess_with_queues(compiler_path, stream_port) to_child.put(['compile', [labscript_file, run_file]]) while True: signal, data = from_child.get() if signal == 'done': success = data to_child.put(['quit', None]) child.communicate() done_callback(success) break else: raise RuntimeError((signal, data))