[FIX] race condition for test cursors
If a test ends before handling all its http queries (serialised by a Rlock), threads created for unfufilled queries may hang because the interrupted thread might not have unlocked its cursor as it might have dissapeared from HTTP_SESSION before request release_test_cursor. We now use the cursor itself instead of HTTP_SESSION. bzr revid: al@openerp.com-20140317031448-rffj7gixgk8jzeqp
This commit is contained in:
parent
706ef452cb
commit
338c0a3f5e
|
@ -181,7 +181,7 @@ class WebRequest(object):
|
||||||
|
|
||||||
if self._cr:
|
if self._cr:
|
||||||
# Dont commit test cursors
|
# Dont commit test cursors
|
||||||
if not openerp.tests.common.release_test_cursor(self.session_id):
|
if not openerp.tests.common.release_test_cursor(self._cr):
|
||||||
if exc_type is None:
|
if exc_type is None:
|
||||||
self._cr.commit()
|
self._cr.commit()
|
||||||
self._cr.close()
|
self._cr.close()
|
||||||
|
|
|
@ -48,10 +48,9 @@ def acquire_test_cursor(session_id):
|
||||||
cr._test_lock.acquire()
|
cr._test_lock.acquire()
|
||||||
return cr
|
return cr
|
||||||
|
|
||||||
def release_test_cursor(session_id):
|
def release_test_cursor(cr):
|
||||||
if openerp.tools.config['test_enable']:
|
if openerp.tools.config['test_enable']:
|
||||||
cr = HTTP_SESSION.get(session_id)
|
if hasattr(cr, '_test_lock'):
|
||||||
if cr:
|
|
||||||
cr._test_lock.release()
|
cr._test_lock.release()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue