[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:
Antony Lesuisse 2014-03-17 04:14:48 +01:00
parent 706ef452cb
commit 338c0a3f5e
2 changed files with 3 additions and 4 deletions

View File

@ -181,7 +181,7 @@ class WebRequest(object):
if self._cr:
# 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:
self._cr.commit()
self._cr.close()

View File

@ -48,10 +48,9 @@ def acquire_test_cursor(session_id):
cr._test_lock.acquire()
return cr
def release_test_cursor(session_id):
def release_test_cursor(cr):
if openerp.tools.config['test_enable']:
cr = HTTP_SESSION.get(session_id)
if cr:
if hasattr(cr, '_test_lock'):
cr._test_lock.release()
return True
return False