def post_install(self): exe = py_exe(self._conda_dir) # Add Pyzo channel cmd = [ exe, '-m', 'conda', 'config', '--system', '--add', 'channels', 'pyzo' ] subprocess.check_call(cmd, shell=sys.platform.startswith('win')) self.addStatus('Added Pyzo channel to conda env') # Add to pyzo shell config first = None if pyzo.config.shellConfigs2 and pyzo.config.shellConfigs2[0][ 'exe'] == exe: pass else: s = pyzo.ssdf.new() s.name = 'Py3-conda' s.exe = exe s.gui = 'PyQt4' pyzo.config.shellConfigs2.insert(0, s) pyzo.saveConfig() self.addStatus('Prepended new env to Pyzo shell configs.')
def closeEvent(self, event): """ Override close event handler. """ # Are we restaring? restarting = time.time() - self._closeflag < 1.0 # Save settings pyzo.saveConfig() pyzo.command_history.save() # Stop command server commandline.stop_our_server() # Proceed with closing... result = pyzo.editors.closeAll() if not result: self._closeflag = False event.ignore() return else: self._closeflag = True #event.accept() # Had to comment on Windows+py3.3 to prevent error # Proceed with closing shells pyzo.localKernelManager.terminateAll() for shell in pyzo.shells: shell._context.close() # Close tools for toolname in pyzo.toolManager.getLoadedTools(): tool = pyzo.toolManager.getTool(toolname) tool.close() # Stop all threads (this should really only be daemon threads) import threading for thread in threading.enumerate(): if hasattr(thread, 'stop'): try: thread.stop(0.1) except Exception: pass # # Wait for threads to die ... # # This should not be necessary, but I used it in the hope that it # # would prevent the segfault on Python3.3. It didn't. # timeout = time.time() + 0.5 # while threading.activeCount() > 1 and time.time() < timeout: # time.sleep(0.1) # print('Number of threads alive:', threading.activeCount()) # Proceed as normal QtWidgets.QMainWindow.closeEvent(self, event) # Harder exit to prevent segfault. Not really a solution, # but it does the job until Pyside gets fixed. if sys.version_info >= (3, 3, 0) and not restarting: if hasattr(os, '_exit'): os._exit(0)
def closeEvent(self, event): """ Override close event handler. """ # Are we restaring? restarting = time.time() - self._closeflag < 1.0 # Save settings pyzo.saveConfig() pyzo.command_history.save() # Stop command server commandline.stop_our_server() # Proceed with closing... result = pyzo.editors.closeAll() if not result: self._closeflag = False event.ignore() return else: self._closeflag = True #event.accept() # Had to comment on Windows+py3.3 to prevent error # Proceed with closing shells pyzo.localKernelManager.terminateAll() for shell in pyzo.shells: shell._context.close() # Close tools for toolname in pyzo.toolManager.getLoadedTools(): tool = pyzo.toolManager.getTool(toolname) tool.close() # Stop all threads (this should really only be daemon threads) import threading for thread in threading.enumerate(): if hasattr(thread, 'stop'): try: thread.stop(0.1) except Exception: pass # # Wait for threads to die ... # # This should not be necessary, but I used it in the hope that it # # would prevent the segfault on Python3.3. It didn't. # timeout = time.time() + 0.5 # while threading.activeCount() > 1 and time.time() < timeout: # time.sleep(0.1) # print('Number of threads alive:', threading.activeCount()) # Proceed as normal QtWidgets.QMainWindow.closeEvent(self, event) # Harder exit to prevent segfault. Not really a solution, # but it does the job until Pyside gets fixed. if sys.version_info >= (3,3,0) and not restarting: if hasattr(os, '_exit'): os._exit(0)
def closeEvent(self, event): """Override close event handler.""" # Are we restaring? restarting = time.time() - self._closeflag < 1.0 # noqa: F841 # Save settings pyzo.saveConfig() pyzo.command_history.save() # Stop command server commandline.stop_our_server() # Proceed with closing... result = pyzo.editors.closeAll() if not result: self._closeflag = False event.ignore() return else: self._closeflag = True # event.accept() # Had to comment on Windows+py3.3 to prevent error # Proceed with closing shells pyzo.localKernelManager.terminateAll() for shell in pyzo.shells: shell._context.close() # The tools need to be explicitly closed to allow them to clean up for toolname in pyzo.toolManager.getLoadedTools(): tool = pyzo.toolManager.getTool(toolname) if hasattr(tool, "cleanUp"): tool.cleanUp() # Stop all threads (this should really only be daemon threads) import threading for thread in threading.enumerate(): if hasattr(thread, "stop"): try: thread.stop(0.1) except Exception: pass # # Wait for threads to die ... # # This should not be necessary, but I used it in the hope that it # # would prevent the segfault on Python3.3. It didn't. # timeout = time.time() + 0.5 # while threading.activeCount() > 1 and time.time() < timeout: # time.sleep(0.1) # print('Number of threads alive:', threading.activeCount()) # Proceed as normal QtWidgets.QMainWindow.closeEvent(self, event)
def closeEvent(self, event): ''' A monkey-patched version of MainWindow.closeEvent. Copyright (C) 2013-2018, the Pyzo development team ''' # pylint: disable=no-member, not-an-iterable # Pylint gets confused by monkey-patches. if g: g.pr('PATCHED MainWindow.closeEvent') # Are we restaring? # restarting = time.time() - self._closeflag < 1.0 # Save settings pyzo.saveConfig() pyzo.command_history.save() # Stop command server commandline.stop_our_server() # Proceed with closing... result = pyzo.editors.closeAll() if 0: # Force the close. if not result: self._closeflag = False event.ignore() return self._closeflag = True # Proceed with closing shells pyzo.localKernelManager.terminateAll() for shell in pyzo.shells: shell._context.close() # Close tools for toolname in pyzo.toolManager.getLoadedTools(): tool = pyzo.toolManager.getTool(toolname) tool.close() # Stop all threads (this should really only be daemon threads) import threading for thread in threading.enumerate(): if hasattr(thread, 'stop'): try: thread.stop(0.1) except Exception: pass # Proceed as normal QtWidgets.QMainWindow.closeEvent(self, event)
def post_install(self): exe = py_exe(self._conda_dir) # Add Pyzo channel cmd = [exe, "-m", "conda", "config", "--system", "--add", "channels", "pyzo"] subprocess.check_call(cmd, shell=sys.platform.startswith("win")) self.addStatus("Added Pyzo channel to conda env") # Add to pyzo shell config if pyzo.config.shellConfigs2 and pyzo.config.shellConfigs2[0]["exe"] == exe: pass else: s = pyzo.ssdf.new() s.name = "Py3-conda" s.exe = exe s.gui = "PyQt4" pyzo.config.shellConfigs2.insert(0, s) pyzo.saveConfig() self.addStatus("Prepended new env to Pyzo shell configs.")
def post_install(self): exe = py_exe(self._conda_dir) # Add Pyzo channel cmd = [exe, "-m", "conda", "config", "--system", "--add", "channels", "pyzo"] subprocess.check_call(cmd, shell=sys.platform.startswith("win")) self.addStatus("Added Pyzo channel to conda env") # Add to pyzo shell config first = None if pyzo.config.shellConfigs2 and pyzo.config.shellConfigs2[0]["exe"] == exe: pass else: s = pyzo.ssdf.new() s.name = "Py3-conda" s.exe = exe s.gui = "PyQt4" pyzo.config.shellConfigs2.insert(0, s) pyzo.saveConfig() self.addStatus("Prepended new env to Pyzo shell configs.")
def post_install(self): exe = py_exe(self._conda_dir) # Add Pyzo channel cmd = [exe, '-m', 'conda', 'config', '--system', '--add', 'channels', 'pyzo'] subprocess.check_call(cmd, shell=sys.platform.startswith('win')) self.addStatus('Added Pyzo channel to conda env') # Add to pyzo shell config first = None if pyzo.config.shellConfigs2 and pyzo.config.shellConfigs2[0]['exe'] == exe: pass else: s = pyzo.ssdf.new() s.name = 'Py3-conda' s.exe = exe s.gui='PyQt4' pyzo.config.shellConfigs2.insert(0, s) pyzo.saveConfig() self.addStatus('Prepended new env to Pyzo shell configs.')
def closeEvent(self, event): """ Override close event handler. """ import pyzo.core.commandline as commandline g.pr('\nMainWindowShim.closeEvent 1') t1 = time.process_time() # Are we restaring? ### restarting = time.time() - self._closeflag < 1.0 # Save settings pyzo.saveConfig() pyzo.command_history.save() # Stop command server commandline.stop_our_server() # Proceed with closing... result = pyzo.editors.closeAll() if not result: self._closeflag = False event.ignore() return else: self._closeflag = True t2 = time.process_time() # Proceed with closing shells pyzo.localKernelManager.terminateAll() # pylint: disable=no-member for shell in pyzo.shells: shell._context.close() t3 = time.process_time() # Close tools for toolname in pyzo.toolManager.getLoadedTools(): tool = pyzo.toolManager.getTool(toolname) tool.close() t4 = time.process_time() # Stop all threads (this should really only be daemon threads) import threading for thread in threading.enumerate(): if hasattr(thread, 'stop'): try: thread.stop(0.1) except Exception: pass t5 = time.process_time() if 1: # EKR g.pr('\nMainWindowShim.closeEvent 2') g.pr('stage 1: %5.2f' % (t2 - t1)) g.pr('stage 2: shells: %5.2f' % (t3 - t2)) g.pr('stage 3: tools: %5.2f' % (t4 - t3)) g.pr('stage 4: threads: %5.2f' % (t5 - t4)) # Proceed as normal QtWidgets.QMainWindow.closeEvent(self, event) # Harder exit to prevent segfault. Not really a solution, # but it does the job until Pyside gets fixed. if sys.version_info >= (3, 3, 0): # and not restarting: if hasattr(os, '_exit'): os._exit(0)