From ce4cc9106695143300d4dcba2ef27fc112427d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 30 Sep 2008 11:50:45 +0200 Subject: [PATCH] Improve semaphore on rpc.execute --- tryton/rpc.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tryton/rpc.py b/tryton/rpc.py index cfadfffdbe..c71fdf8951 100644 --- a/tryton/rpc.py +++ b/tryton/rpc.py @@ -161,21 +161,17 @@ def execute(obj, method, *args): if key in _VIEW_CACHE and _VIEW_CACHE[key][0]: args = args[:] args = args + (_VIEW_CACHE[key][0],) + _SEMAPHORE.acquire() try: - _SEMAPHORE.acquire() try: _SOCK.send((obj, method, _DATABASE, _USER, _SESSION) + args) result = _SOCK.receive() - finally: - _SEMAPHORE.release() - except socket.error: - _SEMAPHORE.acquire() - try: + except socket.error: _SOCK.reconnect() _SOCK.send((obj, method, _DATABASE, _USER, _SESSION) + args) result = _SOCK.receive() - finally: - _SEMAPHORE.release() + finally: + _SEMAPHORE.release() if key: if result is True and key in _VIEW_CACHE: result = _VIEW_CACHE[key][1]