Add a non blocking rpc execute and use it for request_set
This commit is contained in:
1 parent
7c28bd8ede
commit
1aafb3b1f4
2 files changed
+19
-4
No files matched your search
+9
-2
@@ -326,8 +326,15 @@ class Main(object):
|
||||
|
||||
def request_set(self, exception=False):
|
||||
try:
|
||||
ids, ids2 = rpc.execute('object', 'execute',
|
||||
'res.request', 'request_get')
|
||||
if not exception:
|
||||
res = rpc.execute('object', 'execute',
|
||||
'res.request', 'request_get')
|
||||
if not res:
|
||||
return ([], [])
|
||||
ids1, ids2 = res
|
||||
else:
|
||||
ids, ids2 = rpc.execute('object', 'execute',
|
||||
'res.request', 'request_get')
|
||||
if len(ids):
|
||||
if len(ids) == 1:
|
||||
message = _('%s request') % len(ids)
|
||||
|
||||
+10
-2
@@ -150,7 +150,7 @@ def context_reload():
|
||||
except:
|
||||
pass
|
||||
|
||||
def execute(obj, method, *args):
|
||||
def _execute(blocking, obj, method, *args):
|
||||
global _SOCK, _DATABASE, _USER, _SESSION
|
||||
if not _SOCK or not _SOCK.connected:
|
||||
raise Exception('NotLogged')
|
||||
@@ -161,7 +161,9 @@ 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()
|
||||
res = _SEMAPHORE.acquire(blocking)
|
||||
if not res:
|
||||
return
|
||||
try:
|
||||
try:
|
||||
_SOCK.send((obj, method, _DATABASE, _USER, _SESSION) + args)
|
||||
@@ -179,6 +181,12 @@ def execute(obj, method, *args):
|
||||
_VIEW_CACHE[key] = (result['md5'], result)
|
||||
return result
|
||||
|
||||
def execute(obj, method, *args):
|
||||
return _execute(True, obj, method, *args)
|
||||
|
||||
def execute_nonblocking(obj, method, *args):
|
||||
return _execute(False, obj, method, *args)
|
||||
|
||||
class RPCProxy(object):
|
||||
|
||||
def __init__(self, name):
|
||||
|
||||
Reference in new issue
Block a user