Netsvc.Server: Expand tabs

bzr revid: p_christ@hol.gr-20091027223937-ajgpml2uh2afe988
This commit is contained in:
P. Christeas 2009-10-28 00:39:37 +02:00
parent 6affaee1ab
commit cac0ce70e4
1 changed files with 39 additions and 39 deletions

View File

@ -290,47 +290,47 @@ class Agent(object):
import traceback import traceback
class Server: class Server:
""" Generic interface for all servers with an event loop etc. """ Generic interface for all servers with an event loop etc.
Override this to impement http, net-rpc etc. servers. Override this to impement http, net-rpc etc. servers.
Servers here must have threaded behaviour. start() must not block, Servers here must have threaded behaviour. start() must not block,
there is no run(). there is no run().
""" """
__is_started = False __is_started = False
__servers = [] __servers = []
def __init__(self): def __init__(self):
if Server.__is_started: if Server.__is_started:
raise Exception('All instances of servers must be inited before the startAll()') raise Exception('All instances of servers must be inited before the startAll()')
Server.__servers.append(self) Server.__servers.append(self)
def start(self): def start(self):
print "called stub Server.start" print "called stub Server.start"
pass pass
def stop(self): def stop(self):
print "called stub Server.stop" print "called stub Server.stop"
pass pass
@classmethod @classmethod
def startAll(cls): def startAll(cls):
if cls.__is_started: if cls.__is_started:
return return
Logger().notifyChannel("services", LOG_INFO, Logger().notifyChannel("services", LOG_INFO,
"Starting %d services" % len(cls.__servers)) "Starting %d services" % len(cls.__servers))
for srv in cls.__servers: for srv in cls.__servers:
srv.start() srv.start()
cls.__is_started = True cls.__is_started = True
@classmethod @classmethod
def quitAll(cls): def quitAll(cls):
if not cls.__is_started: if not cls.__is_started:
return return
Logger().notifyChannel("services", LOG_INFO, Logger().notifyChannel("services", LOG_INFO,
"Stopping %d services" % len(cls.__servers)) "Stopping %d services" % len(cls.__servers))
for srv in cls.__servers: for srv in cls.__servers:
srv.stop() srv.stop()
cls.__is_started = False cls.__is_started = False
class OpenERPDispatcherException(Exception): class OpenERPDispatcherException(Exception):