def setUp(self): context = zmq.Context.instance() self.notify_addr = "inproc://" + uuid.uuid4().hex self.socket_addr = "inproc://" + uuid.uuid4().hex self.kill_pub = context.socket(zmq.PUB) self.kill_pub.bind(self.notify_addr) self.server = KnimeBridgeServer(context, self.socket_addr, self.notify_addr, NOTIFY_STOP) self.server.start() self.session_id = uuid.uuid4().hex self.socket = context.socket(zmq.REQ) self.socket.connect(self.socket_addr)
def main(): # # For OS/X set up the UI elements that users expect from # an app. # if sys.platform == "darwin": import os.path icon_path = pkg_resources.resource_filename( "cellprofiler", os.path.join("data", "icons", "CellProfiler.png")) os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker" os.environ["APP_ICON_%d" % os.getpid()] = icon_path # Start the JVM from cellprofiler_core.utilities.java import start_java, stop_java start_java() deadman_start_socket = the_zmq_context.socket(zmq.PAIR) deadman_start_socket.bind(DEADMAN_START_ADDR) # Start the deadman switch thread. start_daemon_thread(target=exit_on_stdin_close, name="exit_on_stdin_close") deadman_start_socket.recv() deadman_start_socket.close() from cellprofiler.knime_bridge import KnimeBridgeServer with Worker(work_announce_address) as worker: worker_thread = threading.Thread(target=worker.run, name="WorkerThread") worker_thread.setDaemon(True) worker_thread.start() with KnimeBridgeServer(the_zmq_context, knime_bridge_address, NOTIFY_ADDR, NOTIFY_STOP): worker_thread.join() # # Shutdown - need to handle some global cleanup here # try: stop_java() except: logging.warning("Failed to stop the JVM", exc_info=True)
def main(): # # For OS/X set up the UI elements that users expect from # an app. # if sys.platform == "darwin": from cellprofiler.icons import get_builtin_images_path icon_path = os.path.join(get_builtin_images_path(), "artwork/CellProfilerIcon.png") os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker" os.environ["APP_ICON_%d" % os.getpid()] = icon_path # Start the JVM from cellprofiler.utilities.cpjvm import cp_start_vm, cp_stop_vm cp_start_vm() deadman_start_socket = the_zmq_context.socket(zmq.PAIR) deadman_start_socket.bind(DEADMAN_START_ADDR) # Start the deadman switch thread. start_daemon_thread(target=exit_on_stdin_close, name="exit_on_stdin_close") deadman_start_socket.recv() deadman_start_socket.close() from cellprofiler.knime_bridge import KnimeBridgeServer with AnalysisWorker(work_announce_address) as worker: worker_thread = threading.Thread(target=worker.run, name="WorkerThread") worker_thread.setDaemon(True) worker_thread.start() with KnimeBridgeServer(the_zmq_context, knime_bridge_address, NOTIFY_ADDR, NOTIFY_STOP): worker_thread.join() # # Shutdown - need to handle some global cleanup here # try: cp_stop_vm() except: logger.warn("Failed to stop the JVM", exc_info=1)
def main(): # # For Windows build with Ilastik, look for site-packages # in order to find Ilastik sources. # if hasattr(sys, 'frozen') and sys.platform == "win32": root = os.path.split(sys.argv[0])[0] if len(root) == 0: root = os.curdir root = os.path.abspath(root) site_packages = os.path.join(root, 'site-packages').encode('utf-8') if os.path.exists(site_packages) and os.path.isdir(site_packages): import site site.addsitedir(site_packages) # # For OS/X set up the UI elements that users expect from # an app. # if sys.platform == "darwin": from cellprofiler.icons import get_builtin_images_path icon_path = os.path.join(get_builtin_images_path(), "artwork/CellProfilerIcon.png") os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker" os.environ["APP_ICON_%d" % os.getpid()] = icon_path # Start the JVM from cellprofiler.utilities.cpjvm import cp_start_vm, cp_stop_vm cp_start_vm() deadman_start_socket = the_zmq_context.socket(zmq.PAIR) deadman_start_socket.bind(DEADMAN_START_ADDR) # Start the deadman switch thread. start_daemon_thread(target=exit_on_stdin_close, name="exit_on_stdin_close") deadman_start_socket.recv() deadman_start_socket.close() # Limit Ilastik to one job thread. try: from ilastik.core.jobMachine import GLOBAL_WM try: GLOBAL_WM.set_thread_count(1) except: GLOBAL_WM.setThreadCount(1) except: pass from cellprofiler.knime_bridge import KnimeBridgeServer with AnalysisWorker(work_announce_address) as worker: worker_thread = threading.Thread(target=worker.run, name="WorkerThread") worker_thread.setDaemon(True) worker_thread.start() with KnimeBridgeServer(the_zmq_context, knime_bridge_address, NOTIFY_ADDR, NOTIFY_STOP): enter_run_loop() worker_thread.join() # # Shutdown - need to handle some global cleanup here # try: from ilastik.core.jobMachine import GLOBAL_WM GLOBAL_WM.stopWorkers() except: logger.warn("Failed to stop Ilastik") try: cp_stop_vm() except: logger.warn("Failed to stop the JVM", exc_info=1)