valid_traceback = getattr(e, 'traceback', sys.exc_info()) formatted_traceback = "".join( traceback.format_exception(*valid_traceback)) _logger.debug("netrpc: communication-level exception", exc_info=True) ts.mysend(valid_exception, exception=True, traceback=formatted_traceback) break except Exception, ex: #terminate this channel if we can't properly send back the error _logger.exception( "netrpc: cannot deliver exception message to client") break netsvc.close_socket(self.sock) self.sock = None self.threads.remove(self) self.running = False return True def stop(self): self.running = False def netrpc_handle_exception_legacy(e): if isinstance(e, openerp.osv.osv.except_osv): return 'warning -- ' + e.name + '\n\n' + e.value if isinstance(e, openerp.exceptions.Warning): return 'warning -- Warning\n\n' + str(e) if isinstance(e, openerp.exceptions.AccessError):
def disconnect(self): netsvc.close_socket(self.sock)
def _close_socket(self): netsvc.close_socket(self.socket)
#terminate this channel because other endpoint is gone break except Exception, e: try: valid_exception = Exception(netrpc_handle_exception_legacy(e)) valid_traceback = getattr(e, 'traceback', sys.exc_info()) formatted_traceback = "".join(traceback.format_exception(*valid_traceback)) _logger.debug("netrpc: communication-level exception", exc_info=True) ts.mysend(valid_exception, exception=True, traceback=formatted_traceback) break except Exception, ex: #terminate this channel if we can't properly send back the error _logger.exception("netrpc: cannot deliver exception message to client") break netsvc.close_socket(self.sock) self.sock = None self.threads.remove(self) self.running = False return True def stop(self): self.running = False def netrpc_handle_exception_legacy(e): if isinstance(e, openerp.osv.osv.except_osv): return 'warning -- ' + e.name + '\n\n' + e.value if isinstance(e, openerp.exceptions.Warning): return 'warning -- Warning\n\n' + str(e) if isinstance(e, openerp.exceptions.AccessError): return 'warning -- AccessError\n\n' + str(e)