diff --git a/odoo/http.py b/odoo/http.py index 94ec3b8c752..89efcbdeb41 100644 --- a/odoo/http.py +++ b/odoo/http.py @@ -1440,6 +1440,7 @@ class Root(object): httprequest = werkzeug.wrappers.Request(environ) httprequest.app = self httprequest.parameter_storage_class = werkzeug.datastructures.ImmutableOrderedMultiDict + threading.current_thread().url = httprequest.url explicit_session = self.setup_session(httprequest) self.setup_db(httprequest) diff --git a/odoo/service/wsgi_server.py b/odoo/service/wsgi_server.py index 9669fabf5d3..949d6b9b1fc 100644 --- a/odoo/service/wsgi_server.py +++ b/odoo/service/wsgi_server.py @@ -163,6 +163,8 @@ def application_unproxied(environ, start_response): del threading.current_thread().uid if hasattr(threading.current_thread(), 'dbname'): del threading.current_thread().dbname + if hasattr(threading.current_thread(), 'url'): + del threading.current_thread().url with odoo.api.Environment.manage(): # Try all handlers until one returns some result (i.e. not None). diff --git a/odoo/tests/common.py b/odoo/tests/common.py index b27d7a6ba49..5f961e39e41 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -393,11 +393,17 @@ class HttpCase(TransactionCase): t0 = int(time.time()) for thread in threading.enumerate(): if thread.name.startswith('odoo.service.http.request.'): + thread.join_retry_count = 10 while thread.isAlive(): # Need a busyloop here as thread.join() masks signals # and would prevent the forced shutdown. thread.join(0.05) - time.sleep(0.05) + thread.join_retry_count -= 1 + if thread.join_retry_count < 0: + _logger.warning("Stop waiting for thread %s handling request for url %s", + thread.name, thread.url) + break + time.sleep(0.5) t1 = int(time.time()) if t0 != t1: _logger.info('remaining requests') diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py index cb0c662ca49..19470b07b00 100644 --- a/odoo/tools/misc.py +++ b/odoo/tools/misc.py @@ -1038,15 +1038,17 @@ def dumpstacks(sig=None, frame=None): # modified for python 2.5 compatibility threads_info = {th.ident: {'name': th.name, 'uid': getattr(th, 'uid', 'n/a'), - 'dbname': getattr(th, 'dbname', 'n/a')} + 'dbname': getattr(th, 'dbname', 'n/a'), + 'url': getattr(th, 'url', 'n/a')} for th in threading.enumerate()} for threadId, stack in sys._current_frames().items(): thread_info = threads_info.get(threadId, {}) - code.append("\n# Thread: %s (id:%s) (db:%s) (uid:%s)" % + code.append("\n# Thread: %s (id:%s) (db:%s) (uid:%s) (url:%s)" % (thread_info.get('name', 'n/a'), threadId, thread_info.get('dbname', 'n/a'), - thread_info.get('uid', 'n/a'))) + thread_info.get('uid', 'n/a'), + thread_info.get('url', 'n/a'))) for line in extract_stack(stack): code.append(line)