From 8dbee5c4735b381490ee51a66d7cbbbd31ea3f22 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 5 Dec 2012 15:32:22 +0100 Subject: [PATCH] [FIX] service/__init__.py: do not join() main thread bzr revid: chs@openerp.com-20121205143222-vrasdnzhdtdr307c --- openerp/service/__init__.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/openerp/service/__init__.py b/openerp/service/__init__.py index 491af631202..26740ec363b 100644 --- a/openerp/service/__init__.py +++ b/openerp/service/__init__.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). +# Copyright (C) 2010-2012 OpenERP SA () # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -15,7 +16,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -23,10 +24,8 @@ import logging import threading import time -import http_server import netrpc_server import web_services -import websrv_lib import openerp.cron import openerp.modules @@ -61,6 +60,7 @@ Maybe you forgot to add those addons in your addons_path configuration.""" _logger.exception('Failed to load server-wide module `%s`.%s', m, msg) start_internal_done = False +main_thread_id = threading.currentThread().ident def start_internal(): global start_internal_done @@ -99,7 +99,6 @@ def stop_services(): openerp.netsvc.Server.quitAll() openerp.service.wsgi_server.stop_server() - config = openerp.tools.config _logger.info("Initiating shutdown") _logger.info("Hit CTRL-C again or send a second signal to force the shutdown.") logging.shutdown() @@ -107,8 +106,9 @@ def stop_services(): # Manually join() all threads before calling sys.exit() to allow a second signal # to trigger _force_quit() in case some non-daemon threads won't exit cleanly. # threading.Thread.join() should not mask signals (at least in python 2.5). + me = threading.currentThread() for thread in threading.enumerate(): - if thread != threading.currentThread() and not thread.isDaemon(): + if thread != me and not thread.isDaemon() and thread.ident != main_thread_id: while thread.isAlive(): # Need a busyloop here as thread.join() masks signals # and would prevent the forced shutdown. @@ -119,10 +119,9 @@ def stop_services(): def start_services_workers(): import openerp.service.workers - openerp.multi_process = True # Nah! + openerp.multi_process = True openerp.service.workers.Multicorn(openerp.service.wsgi_server.application).run() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -