def exit(self, result=0, msg=None): """Exit the runtime.""" if self._finalizer: try: self._finalizer() except Exception as e: try: NailgunProtocol.send_stderr( self._socket, '\nUnexpected exception in finalizer: {!r}\n'.format( e)) except Exception: pass try: # Write a final message to stderr if present. if msg: NailgunProtocol.send_stderr(self._socket, msg) # Send an Exit chunk with the result. NailgunProtocol.send_exit(self._socket, str(result).encode('ascii')) # Shutdown the connected socket. teardown_socket(self._socket) finally: # N.B. Assuming a fork()'d child, cause os._exit to be called here to avoid the routine # sys.exit behavior (via `pants.util.contextutil.hard_exit_handler()`). raise HardSystemExit()
def exit(self, result=0, msg=None, *args, **kwargs): """Exit the runtime.""" if self._finalizer: try: self._finalizer() except Exception as e: try: NailgunProtocol.send_stderr( self._socket, '\nUnexpected exception in finalizer: {!r}\n'.format( e)) except Exception: pass try: # Write a final message to stderr if present. if msg: NailgunProtocol.send_stderr(self._socket, msg) # Send an Exit chunk with the result. NailgunProtocol.send_exit_with_code(self._socket, result) # Shutdown the connected socket. teardown_socket(self._socket) finally: super(DaemonExiter, self).exit(result=result, *args, **kwargs)
def exit(self, result=0, msg=None): """Exit the runtime.""" if self._finalizer: try: self._finalizer() except Exception as e: try: NailgunProtocol.send_stderr( self._socket, '\nUnexpected exception in finalizer: {!r}\n'.format(e) ) except Exception: pass try: # Write a final message to stderr if present. if msg: NailgunProtocol.send_stderr(self._socket, msg) # Send an Exit chunk with the result. NailgunProtocol.send_exit(self._socket, str(result).encode('ascii')) # Shutdown the connected socket. teardown_socket(self._socket) finally: # N.B. Assuming a fork()'d child, cause os._exit to be called here to avoid the routine # sys.exit behavior (via `pants.util.contextutil.hard_exit_handler()`). raise HardSystemExit()
def exit(self, result=0, msg=None, *args, **kwargs): """Exit the runtime.""" if self._finalizer: try: self._finalizer() except Exception as e: try: with self._maybe_shutdown_socket.lock: NailgunProtocol.send_stderr( self._maybe_shutdown_socket.socket, '\nUnexpected exception in finalizer: {!r}\n'. format(e)) except Exception: pass with self._maybe_shutdown_socket.lock: # Write a final message to stderr if present. if msg: NailgunProtocol.send_stderr(self._maybe_shutdown_socket.socket, msg) # Send an Exit chunk with the result. # This will cause the client to disconnect from the socket. NailgunProtocol.send_exit_with_code( self._maybe_shutdown_socket.socket, result) # Shutdown the connected socket. teardown_socket(self._maybe_shutdown_socket.socket) self._maybe_shutdown_socket.is_shutdown = True
def exit(self, result=0, msg=None, *args, **kwargs): """Exit the runtime.""" if self._finalizer: try: self._finalizer() except Exception as e: try: NailgunProtocol.send_stderr( self._socket, '\nUnexpected exception in finalizer: {!r}\n'.format(e) ) except Exception: pass try: # Write a final message to stderr if present. if msg: NailgunProtocol.send_stderr(self._socket, msg) # Send an Exit chunk with the result. NailgunProtocol.send_exit_with_code(self._socket, result) # Shutdown the connected socket. teardown_socket(self._socket) finally: super(DaemonExiter, self).exit(result=result, *args, **kwargs)