From 58ebd45efed8ee1e30d42a5abfff94080bf45951 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Sat, 24 Sep 2011 18:33:58 +0200 Subject: [PATCH] [IMP] openerp.service: import at the top. bzr revid: vmt@openerp.com-20110924163358-svx1yjuwdybxxr6k --- openerp/service/__init__.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/openerp/service/__init__.py b/openerp/service/__init__.py index 2a4c03a0892..3da7a50e1f0 100644 --- a/openerp/service/__init__.py +++ b/openerp/service/__init__.py @@ -19,10 +19,18 @@ # ############################################################################## +import logging +import threading +import time + import http_server import netrpc_server import web_services +import openerp.netsvc +import openerp.osv +import openerp.tools + #.apidoc title: RPC Services """ Classes of this module implement the network protocols that the @@ -35,14 +43,15 @@ import web_services """ def start_services(): - import openerp - http_server = openerp.service.http_server - netrpc_server = openerp.service.netrpc_server + """ Start all services. + Services include the different servers and cron threads. + + """ # Instantiate local services (this is a legacy design). openerp.osv.osv.start_object_proxy() # Export (for RPC) services. - openerp.service.web_services.start_web_services() + web_services.start_web_services() # Initialize the HTTP stack. http_server.init_servers() @@ -57,10 +66,7 @@ def start_services(): openerp.netsvc.Server.startAll() def stop_services(): - import openerp - import logging - import threading - import time + """ Stop all services. """ openerp.netsvc.Agent.quit() openerp.netsvc.Server.quitAll() config = openerp.tools.config @@ -69,14 +75,14 @@ def stop_services(): logger.info("Hit CTRL-C again or send a second signal to force the shutdown.") logging.shutdown() - # manually join() all threads before calling sys.exit() to allow a second signal + # 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) + # threading.Thread.join() should not mask signals (at least in python 2.5). for thread in threading.enumerate(): if thread != threading.currentThread() and not thread.isDaemon(): while thread.isAlive(): - # need a busyloop here as thread.join() masks signals - # and would present the forced shutdown + # Need a busyloop here as thread.join() masks signals + # and would prevent the forced shutdown. thread.join(0.05) time.sleep(0.05)