From 338c0a3f5e191b44a94e150104652faf64547ca6 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Mon, 17 Mar 2014 04:14:48 +0100 Subject: [PATCH] [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 --- openerp/http.py | 2 +- openerp/tests/common.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/openerp/http.py b/openerp/http.py index 3fc4aeb60f2..34b9cf19abf 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -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() diff --git a/openerp/tests/common.py b/openerp/tests/common.py index 5d3762a6f7d..b0dcac47408 100644 --- a/openerp/tests/common.py +++ b/openerp/tests/common.py @@ -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