Handle correclty httplib.CannotSendRequest on logout

This commit is contained in:
Nicolas Évrard
2011-10-05 07:13:34 +02:00
parent 8d59bfcba1
commit 2565d59d00
4 changed files with 14 additions and 6 deletions
+3 -2
View File
@@ -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]
+4
View File
@@ -5,6 +5,10 @@ from jsonrpc import Fault
TrytonServerError = Fault
class TrytonServerUnavailable(Exception):
pass
class TrytonError(Exception):
def __init__(self, faultCode):
+2 -2
View File
@@ -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
View File
@@ -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':