diff --git a/tryton/common/common.py b/tryton/common/common.py index f80fe6969d..74ffc9d184 100644 --- a/tryton/common/common.py +++ b/tryton/common/common.py @@ -42,7 +42,8 @@ try: except ImportError: pytz = None -from tryton.exceptions import TrytonServerError, TrytonError +from tryton.exceptions import (TrytonServerError, TrytonError, + TrytonServerUnavailable) _ = gettext.gettext @@ -1048,7 +1049,7 @@ def process_exception(exception, *args): return True finally: PLOCK.release() - elif isinstance(exception, socket.error): + elif isinstance(exception, (socket.error, TrytonServerUnavailable)): msg = '' if len(exception.args) > 2: msg = exception.args[1] diff --git a/tryton/exceptions.py b/tryton/exceptions.py index 6807420c6c..bac5bc1a53 100644 --- a/tryton/exceptions.py +++ b/tryton/exceptions.py @@ -5,6 +5,10 @@ from jsonrpc import Fault TrytonServerError = Fault +class TrytonServerUnavailable(Exception): + pass + + class TrytonError(Exception): def __init__(self, faultCode): diff --git a/tryton/gui/window/view_form/screen/screen.py b/tryton/gui/window/view_form/screen/screen.py index e1a85fa7ad..cb3969eb3b 100644 --- a/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/gui/window/view_form/screen/screen.py @@ -14,7 +14,7 @@ from tryton.signal_event import SignalEvent from tryton.common import node_attributes from tryton.config import CONFIG import tryton.common as common -from tryton.exceptions import TrytonServerError +from tryton.exceptions import TrytonServerError, TrytonServerUnavailable from tryton.jsonrpc import JSONEncoder from tryton.common.tdp import DomainParser @@ -620,7 +620,7 @@ class Screen(SignalEvent): rpc.execute('model', 'ir.ui.view_tree_expanded_state', 'set_expanded', self.model_name, json_domain, self.current_view.children_field, json_paths, rpc.CONTEXT) - except TrytonServerError: + except (TrytonServerError, TrytonServerUnavailable): pass def get_tree_domain(self, parent): diff --git a/tryton/rpc.py b/tryton/rpc.py index c75435932d..1965cc9ca5 100644 --- a/tryton/rpc.py +++ b/tryton/rpc.py @@ -1,5 +1,6 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. +import httplib import itertools import logging import socket @@ -10,7 +11,7 @@ from tryton.jsonrpc import ServerProxy, Fault from tryton.fingerprints import Fingerprints from tryton.config import get_config_dir from tryton.ipc import Server as IPCServer -from tryton.exceptions import TrytonServerError +from tryton.exceptions import TrytonServerError, TrytonServerUnavailable CONNECTION = None _USER = None @@ -114,7 +115,7 @@ def logout(): logging.getLogger('rpc.request').info('common.db.logout(%s, %s)' % (_USER, _SESSION)) CONNECTION.common.db.logout(_USER, _SESSION) - except (Fault, socket.error): + except (Fault, socket.error, httplib.CannotSendRequest): pass finally: _SEMAPHORE.release() @@ -176,6 +177,8 @@ def _execute(blocking, *args): args = (_USER, _SESSION) + args[3:] logging.getLogger('rpc.request').info('%s%s' % (name, args)) result = getattr(CONNECTION, name)(*args) + except httplib.CannotSendRequest, exception: + raise TrytonServerUnavailable(exception) finally: _SEMAPHORE.release() if key and method == 'fields_view_get':