def OnExit(self):
     from imagej.imagej2 import allow_quit
     allow_quit()
     from javabridge import deactivate_awt
     deactivate_awt()
     # restore previous exception hook
     sys.excepthook = self.orig_excepthook
 def OnExit(self):
     from imagej.imagej2 import allow_quit
     allow_quit()
     from javabridge import deactivate_awt
     deactivate_awt()
     # restore previous exception hook
     sys.excepthook = self.orig_excepthook
示例#3
0
 def finalize(self, result):
     try:
         javabridge.deactivate_awt()
         import imagej.imagej2
         if imagej.imagej2.the_imagej_context is not None:
             script = """
             new java.lang.Runnable () {
               run: function() {
                 ctx.getContext().dispose();
               }
             }"""
             runnable = javabridge.run_script(
                 script, dict(ctx=imagej.imagej2.the_imagej_context))
             javabridge.execute_runnable_in_main_thread(runnable, True)
             imagej.imagej2.the_imagej_context = None
             javabridge.static_call("java/lang/System", "gc", "()V")
     except:
         pass
     try:
         from ilastik.core.jobMachine import GLOBAL_WM
         GLOBAL_WM.stopWorkers()
     except:
         logging.root.warn("Failed to stop Ilastik")
     try:
         from cellprofiler.utilities.zmqrequest import join_to_the_boundary
         join_to_the_boundary()
     except:
         logging.root.warn("Failed to stop zmq boundary")
 def exit_thread(self):
     from bioformats.formatreader import clear_image_reader_cache
     self.notify_socket.close()
     clear_image_reader_cache()
     J.deactivate_awt()
     J.detach()
     if self.with_stop_run_loop:
         stop_run_loop()
示例#5
0
 def exit_thread(self):
     from bioformats.formatreader import clear_image_reader_cache
     self.notify_socket.close()
     clear_image_reader_cache()
     J.deactivate_awt()
     J.detach()
     if self.with_stop_run_loop:
         stop_run_loop()
示例#6
0
    javabridge.start_vm()
    if sys.platform == 'darwin':
        #
        # For Mac, we need to start an event loop
        # on the main thread and run the UI code
        # on a worker thread.
        #
        import threading
        javabridge.mac_run_loop_init()

        class Runme(threading.Thread):
            def run(self):
                javabridge.attach()
                try:
                    main(sys.argv)
                finally:
                    javabridge.detach()

        t = Runme()
        t.start()
        javabridge.mac_enter_run_loop()
    else:
        #
        # For everyone else, the event loop
        # is run by Java and we do everything
        # on the main thread.
        #
        main(sys.argv)
    javabridge.deactivate_awt()
    javabridge.kill_vm()
if __name__=="__main__":
    javabridge.start_vm()
    if sys.platform == 'darwin':
        #
        # For Mac, we need to start an event loop
        # on the main thread and run the UI code
        # on a worker thread.
        #
        import threading
        javabridge.mac_run_loop_init()
        class Runme(threading.Thread):
            def run(self):
                javabridge.attach()
                try:
                    main(sys.argv)
                finally:
                    javabridge.detach()
        t = Runme()
        t.start()
        javabridge.mac_enter_run_loop()
    else:
        #
        # For everyone else, the event loop
        # is run by Java and we do everything
        # on the main thread.
        #
        main(sys.argv)
    javabridge.deactivate_awt()
    javabridge.kill_vm()