From f0dcf52159eb3c62b2a878ad51686065986966b7 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 11 Apr 2014 16:36:45 +0200 Subject: [PATCH] [FIX] instrumentation to debug a deadlock probably due to a race condition in the test cursor bzr revid: al@openerp.com-20140411143645-ojb4t9plop4dmizh --- openerp/tests/common.py | 6 ++++++ openerp/tools/misc.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/openerp/tests/common.py b/openerp/tests/common.py index 7cc753e810b..e881959a31b 100644 --- a/openerp/tests/common.py +++ b/openerp/tests/common.py @@ -233,6 +233,7 @@ class HttpCase(TransactionCase): _logger.info("phantom_run execution finished") def _wait_remaining_requests(self): + t0 = int(time.time()) for thread in threading.enumerate(): if thread.name.startswith('openerp.service.http.request.'): while thread.isAlive(): @@ -240,6 +241,11 @@ class HttpCase(TransactionCase): # and would prevent the forced shutdown. thread.join(0.05) time.sleep(0.05) + t1 = int(time.time()) + if t0 != t1: + _logger.info('remaining requests') + openerp.tools.misc.dumpstacks() + t0 = t1 def phantom_jsfile(self, jsfile, timeout=60, **kw): options = { diff --git a/openerp/tools/misc.py b/openerp/tools/misc.py index bb61fe2e7a2..d63e2a987e9 100644 --- a/openerp/tools/misc.py +++ b/openerp/tools/misc.py @@ -1171,7 +1171,7 @@ class ConstantMapping(Mapping): return self._value -def dumpstacks(sig, frame): +def dumpstacks(sig=None, frame=None): """ Signal handler: dump a stack trace for each existing thread.""" code = []