Handle correclty httplib.CannotSendRequest on logout
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -5,6 +5,10 @@ from jsonrpc import Fault
|
||||
TrytonServerError = Fault
|
||||
|
||||
|
||||
class TrytonServerUnavailable(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class TrytonError(Exception):
|
||||
|
||||
def __init__(self, faultCode):
|
||||
|
||||
@@ -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):
|
||||
|
||||
+5
-2
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user