Пример #1
0
    def run(self):
        self.running = True
        try:
            ts = tiny_socket.mysocket(self.sock)
        except Exception:
            self.threads.remove(self)
            self.running = False
            return False

        while self.running:
            try:
                msg = ts.myreceive()
                result = netsvc.dispatch_rpc(msg[0], msg[1], msg[2:])
                ts.mysend(result)
            except socket.timeout:
                #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
Пример #2
0
    def run(self):
        self.running = True
        try:
            ts = tiny_socket.mysocket(self.sock)
        except Exception:
            self.threads.remove(self)
            self.running = False
            return False

        while self.running:
            try:
                msg = ts.myreceive()
                result = netsvc.dispatch_rpc(msg[0], msg[1], msg[2:])
                ts.mysend(result)
            except socket.timeout:
                #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
Пример #3
0
    def run(self):
        self.running = True
        try:
            ts = tiny_socket.mysocket(self.sock)
        except Exception:
            self.threads.remove(self)
            self.running = False
            return False

        while self.running:
            try:
                msg = ts.myreceive()
                result = self.dispatch(msg[0], msg[1], msg[2:])
                ts.mysend(result)
            except socket.timeout:
                #terminate this channel because other endpoint is gone
                break
            except netsvc.OpenERPDispatcherException, e:
                try:
                    new_e = Exception(tools.exception_to_unicode(e.exception)) # avoid problems of pickeling
                    logging.getLogger('web-services').debug("netrpc: rpc-dispatching exception", exc_info=True)
                    ts.mysend(new_e, exception=True, traceback=e.traceback)
                except Exception:
                    #terminate this channel if we can't properly send back the error
                    logging.getLogger('web-services').exception("netrpc: cannot deliver exception message to client")
                    break
            except Exception, e:
                try:
                    tb = getattr(e, 'traceback', sys.exc_info())
                    tb_s = "".join(traceback.format_exception(*tb))
                    logging.getLogger('web-services').debug("netrpc: communication-level exception", exc_info=True)
                    ts.mysend(e, exception=True, traceback=tb_s)
                    break
                except Exception, ex:
                    #terminate this channel if we can't properly send back the error
                    logging.getLogger('web-services').exception("netrpc: cannot deliver exception message to client")
                    break