From ada2e694fc44060200619d0048c27f541c6bd766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 5 Oct 2012 18:31:00 +0200 Subject: [PATCH] Restore Concurrency exception with RPCProgress issue2789 review549003 (transplanted from 532d1c16e16b84f2bcf3f0f8299356c509cd85a8) --- tryton/common/common.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/tryton/common/common.py b/tryton/common/common.py index fd3c32fa61..c1f3d5a3da 100644 --- a/tryton/common/common.py +++ b/tryton/common/common.py @@ -952,6 +952,8 @@ PLOCK = Lock() def process_exception(exception, *args, **kwargs): + rpc_execute = kwargs.get('rpc_execute', rpc.execute) + if isinstance(exception, TrytonError): if exception.faultCode == 'BadFingerprint': warning( @@ -977,14 +979,15 @@ def process_exception(exception, *args, **kwargs): 'always': (res == 'always'), }, rpc.CONTEXT) try: - rpc.execute(*args2) + rpc_execute(*args2) except TrytonServerError, exception: process_exception(exception, *args2) if args: try: - return rpc.execute(*args) + return rpc_execute(*args) except TrytonServerError, exception: - return process_exception(exception, *args) + return process_exception(exception, *args, + rpc_execute=rpc_execute) return True return False elif exception.faultCode == 'UserError': @@ -997,9 +1000,10 @@ def process_exception(exception, *args, **kwargs): if '_timestamp' in args[5]: del args[5]['_timestamp'] try: - return rpc.execute(*args) + return rpc_execute(*args) except TrytonServerError, exception: - return process_exception(exception, *args) + return process_exception(exception, *args, + rpc_execute=rpc_execute) return False else: message(_('Concurrency Exception'), msg_type=gtk.MESSAGE_ERROR) @@ -1027,9 +1031,10 @@ def process_exception(exception, *args, **kwargs): continue if args: try: - return rpc.execute(*args) + return rpc_execute(*args) except TrytonServerError, exception: - return process_exception(exception, *args) + return process_exception(exception, *args, + rpc_execute=rpc_execute) return True finally: PLOCK.release() @@ -1256,12 +1261,14 @@ class RPCProgress(object): gtk.main_iteration() if self.exception: if process_exception_p: - if process_exception(self.exception): - self.res = None - self.error = False - self.exception = None - return self.run(process_exception_p) - raise RPCException(self.exception) + def rpc_execute(*args): + return RPCProgress('execute', + args).run(process_exception_p, main_iteration_p) + result = process_exception(self.exception, *self.args, + rpc_execute=rpc_execute) + if result is False: + raise RPCException(self.exception) + return result else: raise self.exception return self.res