Ejemplo n.º 1
0
 def _start(self):
     if not self._is_setup:
         self.setup()
         self._is_setup = True
     Engine._start(self)
     self.start_http_server()
     if self.blocking:
         self.block()
Ejemplo n.º 2
0
 def __init__(self):
     Engine.__init__(self)
     self._is_setup = False
     self.blocking = True
     
     self.httpserver = None
     # Starting in 2.2, the "httpserverclass" attr is essentially dead;
     # no CP code uses it. Inspect "httpserver" instead.
     self.httpserverclass = None
     
     # Backward compatibility:
     self.onStopServerList = self.on_stop_server_list
     self.onStartThreadList = self.on_start_thread_list
     self.onStartServerList = self.on_start_server_list
     self.onStopThreadList = self.on_stop_thread_list
Ejemplo n.º 3
0
 def start(self, init_only=False, server_class=_missing, server=None, **kwargs):
     """Main function. MUST be called from the main thread.
     
     Set initOnly to True to keep this function from blocking.
     Set serverClass and server to None to skip starting any HTTP server.
     """
     
     # Read old variable names for backward compatibility
     if 'initOnly' in kwargs:
         init_only = kwargs['initOnly']
     if 'serverClass' in kwargs:
         server_class = kwargs['serverClass']
     
     conf = cherrypy.config.get
     
     if not init_only:
         init_only = conf('server.init_only', False)
     
     if server is None:
         server = conf('server.instance', None)
     if server is None:
         if server_class is _missing:
             server_class = conf("server.class", _missing)
         if server_class is _missing:
             import _cpwsgi
             server_class = _cpwsgi.WSGIServer
         elif server_class and isinstance(server_class, basestring):
             # Dynamically load the class from the given string
             server_class = cptools.attributes(server_class)
         self.httpserverclass = server_class
         if server_class is not None:
             self.httpserver = server_class()
     else:
         if isinstance(server, basestring):
             server = cptools.attributes(server)
         self.httpserverclass = server.__class__
         self.httpserver = server
     
     self.blocking = not init_only
     Engine.start(self)
Ejemplo n.º 4
0
 def stop(self):
     """Stop, including any HTTP servers."""
     self.stop_http_server()
     Engine.stop(self)
Ejemplo n.º 5
0
 def wait(self):
     """Block the caller until ready to receive requests (or error)."""
     Engine.wait(self)
     self.wait_for_http_ready()