def stop_services(): """ Stop all services. """ # stop services if not openerp.evented: cron.stop_service() wsgi_server.stop_service() _logger.info("Initiating shutdown") _logger.info("Hit CTRL-C again or send a second signal to force the shutdown.") # 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() _logger.debug('current thread: %r', me) for thread in threading.enumerate(): _logger.debug('process %r (%r)', thread, thread.isDaemon()) if thread != me and not thread.isDaemon() and thread.ident != main_thread_id: while thread.isAlive(): _logger.debug('join and sleep') # Need a busyloop here as thread.join() masks signals # and would prevent the forced shutdown. thread.join(0.05) time.sleep(0.05) _logger.debug('--') openerp.modules.registry.RegistryManager.delete_all() logging.shutdown()
def stop_services(): """ Stop all services. """ # stop services cron.stop_service() netrpc_server.stop_service() wsgi_server.stop_service() _logger.info("Initiating shutdown") _logger.info("Hit CTRL-C again or send a second signal to force the shutdown.") # 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() _logger.debug("current thread: %r", me) for thread in threading.enumerate(): _logger.debug("process %r (%r)", thread, thread.isDaemon()) if thread != me and not thread.isDaemon() and thread.ident != main_thread_id: while thread.isAlive(): _logger.debug("join and sleep") # Need a busyloop here as thread.join() masks signals # and would prevent the forced shutdown. thread.join(0.05) time.sleep(0.05) _logger.debug("--") openerp.modules.registry.RegistryManager.delete_all() logging.shutdown()