Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1092

Show
Ignore:
Timestamp:
05/04/06 02:44:59
Author:
fumanchu
Message:

Separated cherrypy.server (HTTP) from cherrypy.engine (app):

  1. Most CP apps must now make both a call to cherrypy.server.start(server=None) and a call to cherrypy.engine.start(blocking=True).
  2. The on_start_server_list and on_stop_server_list are now on_start_engine_list and on_stop_engine_list.
  3. "start_with_callback" is now an attribute of Engine. So is "request".
  4. Server.start now takes a single "server" arg, which can be a server instance, a string (fully qualified class name), or None (to start the default WSGI server).
  5. Server still has a wait method, but otherwise does no blocking.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/__init__.py

    r1091 r1092  
    1414tree = _cptree.Tree() 
    1515 
    16 # Legacy code may clobber this. 
    1716root = None 
    1817 
     18import _cpengine 
     19engine = _cpengine.Engine() 
    1920import _cpserver 
    2021server = _cpserver.Server() 
  • trunk/cherrypy/_cpengine.py

    r1070 r1092  
    1 """Create and manage the CherryPy application server engine.""" 
     1"""Create and manage the CherryPy application engine.""" 
    22 
    33import cgi 
     
    55import threading 
    66import time 
    7 import warnings 
    87 
    98import cherrypy 
     
    1110from cherrypy.lib import autoreload, profiler, cptools 
    1211 
    13 # Use a flag to indicate the state of the application server
     12# Use a flag to indicate the state of the application engine
    1413STOPPED = 0 
    1514STARTING = None 
     
    1817 
    1918class Engine(object): 
    20     """The application server engine, connecting HTTP servers to Requests.""" 
     19    """The application engine, which exposes a request interface to (HTTP) servers.""" 
    2120     
    2221    request_class = _cprequest.Request 
     
    2524    def __init__(self): 
    2625        self.state = STOPPED 
    27          
    28         self.seen_threads = {} 
    2926        self.interrupt = None 
    3027         
    3128        # Startup/shutdown hooks 
    32         self.on_start_server_list = [] 
    33         self.on_stop_server_list = [] 
     29        self.on_start_engine_list = [] 
     30        self.on_stop_engine_list = [] 
    3431        self.on_start_thread_list = [] 
    3532        self.on_stop_thread_list = [] 
    36      
    37     def setup(self): 
    38         # The only reason this method isn't in __init__ is so that 
    39         # "import cherrypy" can create an Engine() without a circular ref. 
     33        self.seen_threads = {} 
     34     
     35    def start(self, blocking=True): 
     36        """Start the application engine.""" 
     37        self.state = STARTING 
     38        self.interrupt = None 
     39         
    4040        conf = cherrypy.config.get 
    4141         
     
    5757            covercp.start() 
    5858         
    59         # If sessions are stored in files and we 
    60         # use threading, we need a lock on the file 
    61         if (conf('server.thread_pool') > 1 
    62             and conf('session.storage_type') == 'file'): 
    63             cherrypy._sessionFileLock = threading.RLock() 
    64          
    6559        # set cgi.maxlen which will limit the size of POST request bodies 
    6660        cgi.maxlen = conf('server.max_request_size') 
     
    7367            cherrypy.profiler = None 
    7468         
    75     def start(self): 
    76         """Start the application server engine.""" 
    77         self.state = STARTING 
    78         self.interrupt = None 
    79          
    80         conf = cherrypy.config.get 
    81          
    8269        # Autoreload. Note that, if we're not starting our own HTTP server, 
    8370        # autoreload could do Very Bad Things when it calls sys.exit, but 
     
    8673            try: 
    8774                freq = conf('autoreload.frequency', 1) 
    88                 autoreload.main(self._start, freq=freq) 
     75                autoreload.main(self._start, args=(blocking,), freq=freq) 
    8976            except KeyboardInterrupt: 
    9077                cherrypy.log("<Ctrl-C> hit: shutting down autoreloader", "ENGINE") 
     78                cherrypy.server.stop() 
    9179                self.stop() 
    9280            except SystemExit: 
    9381                cherrypy.log("SystemExit raised: shutting down autoreloader", "ENGINE") 
     82                cherrypy.server.stop() 
    9483                self.stop() 
    9584                # We must raise here: if this is a process spawned by 
     
    9988            return 
    10089         
    101         self._start() 
    102      
    103     def _start(self): 
    104         for func in self.on_start_server_list: 
     90        self._start(blocking) 
     91     
     92    def _start(self, blocking=True): 
     93        # This is in a separate function so autoreload can call it. 
     94        for func in self.on_start_engine_list: 
    10595            func() 
    10696        self.state = STARTED 
     97        if blocking: 
     98            self.block() 
    10799     
    108100    def block(self): 
     
    114106                    raise self.interrupt 
    115107        except KeyboardInterrupt: 
    116             cherrypy.log("<Ctrl-C> hit: shutting down app server", "ENGINE") 
     108            cherrypy.log("<Ctrl-C> hit: shutting down app engine", "ENGINE") 
     109            cherrypy.server.stop() 
    117110            self.stop() 
    118111        except SystemExit: 
    119             cherrypy.log("SystemExit raised: shutting down app server", "ENGINE") 
     112            cherrypy.log("SystemExit raised: shutting down app engine", "ENGINE") 
     113            cherrypy.server.stop() 
    120114            self.stop() 
    121115            raise 
     
    123117            # Don't bother logging, since we're going to re-raise. 
    124118            self.interrupt = sys.exc_info()[1] 
     119            # Note that we don't stop the HTTP server here. 
    125120            self.stop() 
    126121            raise 
    127122     
    128123    def stop(self): 
    129         """Stop the application server engine.""" 
     124        """Stop the application engine.""" 
    130125        for thread_ident, i in self.seen_threads.iteritems(): 
    131126            for func in self.on_stop_thread_list: 
     
    133128        self.seen_threads.clear() 
    134129         
    135         for func in self.on_stop_server_list: 
     130        for func in self.on_stop_engine_list: 
    136131            func() 
    137132         
     
    140135     
    141136    def restart(self): 
    142         """Restart the application server engine.""" 
     137        """Restart the application engine (doesn't block).""" 
    143138        self.stop() 
    144         self.start(
     139        self.start(blocking=False
    145140     
    146141    def wait(self): 
     
    149144            time.sleep(.1) 
    150145            if self.interrupt: 
    151                 msg = "The CherryPy application server errored" 
     146                msg = "The CherryPy application engine errored" 
    152147                raise cherrypy.NotReady(msg, "ENGINE") 
    153148     
    154149    def _is_ready(self): 
    155150        return bool(self.state == STARTED) 
    156     ready = property(_is_ready, doc="Return True if the server is ready to" 
     151    ready = property(_is_ready, doc="Return True if the engine is ready to" 
    157152                                    " receive requests, False otherwise.") 
    158153     
    159     def request(self, clientAddress, remote_host, scheme="http"): 
     154    def request(self, client_address, remote_host, scheme="http"): 
    160155        """Obtain an HTTP Request object. 
    161156         
    162         clientAddress: the (IP address, port) of the client 
     157        client_address: the (IP address, port) of the client 
    163158        remote_host: the IP address of the client 
    164159        scheme: either "http" or "https"; defaults to "http" 
    165160        """ 
    166161        if self.state == STOPPED: 
    167             raise cherrypy.NotReady("The CherryPy server has stopped.") 
     162            raise cherrypy.NotReady("The CherryPy engine has stopped.") 
    168163        elif self.state == STARTING: 
    169             raise cherrypy.NotReady("The CherryPy server could not start.") 
     164            raise cherrypy.NotReady("The CherryPy engine could not start.") 
    170165         
    171166        threadID = threading._get_ident() 
     
    182177                func(i) 
    183178         
    184         r = self.request_class(clientAddress[0], clientAddress[1], 
     179        r = self.request_class(client_address[0], client_address[1], 
    185180                               remote_host, scheme) 
    186181        cherrypy.serving.request = r 
    187182        cherrypy.serving.response = self.response_class() 
    188183        return r 
    189  
     184     
     185    def start_with_callback(self, func, args=None, kwargs=None): 
     186        """Start, then callback the given func in a new thread.""" 
     187         
     188        if args is None: 
     189            args = () 
     190        if kwargs is None: 
     191            kwargs = {} 
     192        args = (func,) + args 
     193         
     194        def _callback(func, *a, **kw): 
     195            self.wait() 
     196            func(*a, **kw) 
     197        t = threading.Thread(target=_callback, args=args, kwargs=kwargs) 
     198        t.setName("CPEngine Callback " + t.getName()) 
     199        t.start() 
     200         
     201        self.start() 
     202 
  • trunk/cherrypy/_cpserver.py

    r1047 r1092  
    1 """Create and manage the CherryPy server.""" 
     1"""Manage an HTTP server with CherryPy.""" 
    22 
    33import threading 
     
    66import cherrypy 
    77from cherrypy.lib import cptools 
    8 from cherrypy._cpengine import Engine, STOPPED, STARTING, STARTED 
    9  
    10 _missing = object() 
    118 
    129 
    13 class Server(Engine): 
     10class Server(object): 
     11    """Manager for an HTTP server.""" 
    1412     
    1513    def __init__(self): 
    16         Engine.__init__(self) 
    17         self._is_setup = False 
    18         self.blocking = True 
    19          
    2014        self.httpserver = None 
     15        self.interrupt = None 
    2116     
    22     def start(self, init_only=False, server_class=_missing, server=None, **kwargs): 
    23         """Main function. MUST be called from the main thread. 
    24          
    25         Set initOnly to True to keep this function from blocking. 
    26         Set serverClass and server to None to skip starting any HTTP server. 
    27         """ 
    28          
     17    def start(self, server=None): 
     18        """Main function. MUST be called from the main thread.""" 
    2919        conf = cherrypy.config.get 
    30          
    31         if not init_only: 
    32             init_only = conf('server.init_only', False) 
    33          
    3420        if server is None: 
    3521            server = conf('server.instance', None) 
    3622        if server is None: 
    37             if server_class is _missing: 
    38                 server_class = conf("server.class", _missing) 
    39             if server_class is _missing: 
    40                 import _cpwsgi 
    41                 server_class = _cpwsgi.WSGIServer 
    42             elif server_class and isinstance(server_class, basestring): 
    43                 # Dynamically load the class from the given string 
    44                 server_class = cptools.attributes(server_class) 
    45             if server_class is not None: 
    46                 self.httpserver = server_class() 
    47         else: 
    48             if isinstance(server, basestring): 
    49                 server = cptools.attributes(server) 
    50             self.httpserver = server 
     23            import _cpwsgi 
     24            server = _cpwsgi.WSGIServer() 
     25        if isinstance(server, basestring): 
     26            server = cptools.attributes(server)() 
     27        self.httpserver = server 
    5128         
    52         self.blocking = not init_only 
    53         Engine.start(self) 
    54      
    55     def _start(self): 
    56         if not self._is_setup: 
    57             self.setup() 
    58             self._is_setup = True 
    59         Engine._start(self) 
    60         self.start_http_server() 
    61         if self.blocking: 
    62             self.block() 
    63      
    64     def restart(self): 
    65         """Restart the application server engine.""" 
    66         self.stop() 
    67         self.state = STARTING 
    68         self.interrupt = None 
    69         self._start() 
    70      
    71     def start_http_server(self, blocking=True): 
    72         """Start the requested HTTP server.""" 
    73         if not self.httpserver: 
    74             return 
    75          
    76         if cherrypy.config.get('server.socket_port'): 
    77             host = cherrypy.config.get('server.socket_host') 
    78             port = cherrypy.config.get('server.socket_port') 
    79              
     29        if conf('server.socket_port'): 
     30            host = conf('server.socket_host') 
     31            port = conf('server.socket_port') 
    8032            wait_for_free_port(host, port) 
    81              
    8233            if not host: 
    8334                host = 'localhost' 
    8435            on_what = "http://%s:%s/" % (host, port) 
    8536        else: 
    86             on_what = "socket file: %s" % cherrypy.config.get('server.socket_file') 
     37            on_what = "socket file: %s" % conf('server.socket_file') 
    8738         
    8839        # HTTP servers MUST be started in a new thread, so that the 
    8940        # main thread persists to receive KeyboardInterrupt's. If an 
    90         # exception is raised in the http server's main thread then it's 
    91         # trapped here, and the CherryPy app server is shut down (via 
    92         # self.interrupt). 
     41        # exception is raised in the http server's thread then it's 
     42        # trapped here, and the http server and engine are shut down. 
    9343        def _start_http(): 
    9444            try: 
    9545                self.httpserver.start() 
    9646            except KeyboardInterrupt, exc: 
     47                cherrypy.log("<Ctrl-C> hit: shutting down HTTP server", "SERVER") 
    9748                self.interrupt = exc 
    9849                self.stop() 
     50                cherrypy.engine.stop() 
    9951            except SystemExit, exc: 
     52                cherrypy.log("SystemExit raised: shutting down HTTP server", "SERVER") 
    10053                self.interrupt = exc 
    10154                self.stop() 
     55                cherrypy.engine.stop() 
    10256                raise 
    10357        t = threading.Thread(target=_start_http) 
     
    10559        t.start() 
    10660         
    107         if blocking: 
    108             self.wait_for_http_ready() 
    109          
     61        self.wait() 
    11062        cherrypy.log("Serving HTTP on %s" % on_what, 'HTTP') 
    11163     
    11264    def wait(self): 
    113         """Block the caller until ready to receive requests (or error).""" 
    114         Engine.wait(self) 
    115         self.wait_for_http_ready() 
    116      
    117     def wait_for_http_ready(self): 
    118         if self.httpserver: 
    119             while (not getattr(self.httpserver, "ready", True) 
    120                    and not self.interrupt 
    121                    and self.state != STOPPED): 
    122                 time.sleep(.1) 
     65        """Wait until the HTTP server is ready to receive requests.""" 
     66        while (not getattr(self.httpserver, "ready", True) 
     67               and not self.interrupt): 
     68            time.sleep(.1) 
     69         
     70        # Wait for port to be occupied 
     71        if cherrypy.config.get('server.socket_port'): 
     72            host = cherrypy.config.get('server.socket_host') 
     73            port = cherrypy.config.get('server.socket_port') 
     74            if not host: 
     75                host = 'localhost' 
    12376             
    124             # Wait for port to be occupied 
    125             if cherrypy.config.get('server.socket_port'): 
    126                 host = cherrypy.config.get('server.socket_host') 
    127                 port = cherrypy.config.get('server.socket_port') 
    128                 if not host: 
    129                     host = 'localhost' 
    130                  
    131                 for trial in xrange(50): 
    132                     if self.interrupt: 
    133                         break 
    134                     try: 
    135                         check_port(host, port) 
    136                     except IOError: 
    137                         break 
    138                     else: 
    139                         time.sleep(.1) 
     77            for trial in xrange(50): 
     78                if self.interrupt: 
     79                    break 
     80                try: 
     81                    check_port(host, port) 
     82                except IOError: 
     83                    break 
    14084                else: 
    141                     cherrypy.log("Port %s not bound on %s" % 
    142                                  (repr(port), repr(host)), 'HTTP') 
    143                     raise cherrypy.NotReady("Port not bound.") 
     85                    time.sleep(.1) 
     86            else: 
     87                cherrypy.log("Port %s not bound on %s" % 
     88                             (repr(port), repr(host)), 'HTTP') 
     89                raise cherrypy.NotReady("Port not bound.") 
    14490     
    14591    def stop(self): 
    146         """Stop, including any HTTP servers.""" 
    147         self.stop_http_server() 
    148         Engine.stop(self) 
    149      
    150     def stop_http_server(self): 
    15192        """Stop the HTTP server.""" 
    15293        try: 
     
    159100            cherrypy.log("HTTP Server shut down", "HTTP") 
    160101     
    161     def start_with_callback(self, func, args=None, kwargs=None, 
    162                             server_class = _missing, serverClass = None): 
    163         """Start, then callback the given func in a new thread.""" 
    164          
    165         if args is None: 
    166             args = () 
    167         if kwargs is None: 
    168             kwargs = {} 
    169         args = (func,) + args 
    170          
    171         def _callback(func, *args, **kwargs): 
    172             self.wait() 
    173             func(*args, **kwargs) 
    174         t = threading.Thread(target=_callback, args=args, kwargs=kwargs) 
    175         t.setName("CPServer Callback " + t.getName()) 
    176         t.start() 
    177          
    178         self.start(server_class = server_class) 
     102    def restart(self): 
     103        """Restart the HTTP server.""" 
     104        self.stop() 
     105        self.interrupt = None 
     106        self.start() 
    179107 
    180108 
  • trunk/cherrypy/_cpwsgi.py

    r1090 r1092  
    6666        env = environ.get 
    6767        clientAddr = (env('REMOTE_ADDR', ''), int(env('REMOTE_PORT', -1))) 
    68         request = cherrypy.server.request(clientAddr, env('REMOTE_ADDR', ''), 
     68        request = cherrypy.engine.request(clientAddr, env('REMOTE_ADDR', ''), 
    6969                                          environ['wsgi.url_scheme']) 
    7070        request.login = (env('LOGON_USER') or env('REMOTE_USER') or None) 
  • trunk/cherrypy/lib/covercp.py

    r856 r1092  
    351351                            }) 
    352352    cherrypy.server.start() 
     353    cherrypy.engine.start() 
    353354 
    354355if __name__ == "__main__": 
  • trunk/cherrypy/lib/profiler.py

    r882 r1092  
    137137                            }) 
    138138    cherrypy.server.start() 
     139    cherrypy.engine.start() 
    139140 
    140141 
  • trunk/cherrypy/test/benchmark.py

    r1082 r1092  
    269269started = False 
    270270def startup(req=None): 
    271     """Start the CherryPy app server in 'serverless' mode (for WSGI).""" 
     271    """Start the CherryPy app engine with no server (for WSGI).""" 
    272272    global started 
    273273    if not started: 
    274274        started = True 
    275         cherrypy.server.start(init_only=True, server_class=None) 
     275        cherrypy.engine.start(blocking=False) 
    276276    return 0 # apache.OK 
    277277 
     
    292292            global AB_PATH 
    293293            AB_PATH = ab_opt 
    294         cherrypy.server.start(init_only=True, server_class=None) 
     294        cherrypy.engine.start(blocking=False) 
    295295     
    296296    import modpython_gateway 
     
    384384            cherrypy.server.response_class = NullResponse 
    385385         
     386        cherrypy.server.start() 
    386387        # This will block 
    387         cherrypy.server.start_with_callback(run) 
     388        cherrypy.engine.start_with_callback(run) 
  • trunk/cherrypy/test/helper.py

    r1082 r1092  
    9999    """ 
    100100    setConfig(conf) 
    101     cherrypy.server.start_with_callback(_run_test_suite_thread, 
    102                                         args = (moduleNames, conf)
    103                                         server_class = server
     101    cherrypy.server.start(server) 
     102    cherrypy.engine.start_with_callback(_run_test_suite_thread
     103                                        args=(moduleNames, conf)
    104104 
    105105def _run_test_suite_thread(moduleNames, conf): 
     
    126126    setConfig(conf) 
    127127    try: 
    128         cherrypy.server.start_with_callback(_test_main_thread, *args, **kwargs) 
     128        cherrypy.server.start() 
     129        cherrypy.engine.start_with_callback(_test_main_thread, *args, **kwargs) 
    129130    except KeyboardInterrupt: 
    130131        cherrypy.server.stop() 
     132        cherrypy.engine.stop() 
    131133 
    132134def _test_main_thread(): 
  • trunk/cherrypy/test/modpy.py

    r1036 r1092  
    8686            }) 
    8787        m.setup_server() 
    88         cherrypy.server.start(init_only=True, server_class=None, server=None) 
     88        cherrypy.engine.start(blocking=False) 
    8989    from mod_python import apache 
    9090    return apache.OK 
  • trunk/cherrypy/test/test_noserver.py

    r943 r1092  
    2828 
    2929cherrypy.config.update({"server.environment": "production"}) 
    30 cherrypy.server.start(server_class = None
     30cherrypy.engine.start(
    3131 
  • trunk/cherrypy/test/test_session_concurrency.py

    r941 r1092  
    7777 
    7878# Start server 
    79 thread.start_new_thread(cherrypy.server.start, ()) 
     79cherrypy.server.start() 
     80thread.start_new_thread(cherrypy.engine.start, ()) 
    8081 
    8182# Start client 
     
    108109 
    109110cherrypy.server.stop() 
     111cherrypy.engine.stop() 
    110112 
    111113m = max(data_dict.values()) 
  • trunk/cherrypy/test/test_states.py

    r1023 r1092  
    1717     
    1818    def restart(self): 
    19         cherrypy.server.restart() 
     19        cherrypy.engine.restart() 
    2020        return "app was restarted succesfully" 
    2121    restart.exposed = True 
     
    5656    def test_0_NormalStateFlow(self): 
    5757        if not self.server_class: 
    58             # Without having called "cherrypy.server.start()", we should 
     58            # Without having called "cherrypy.engine.start()", we should 
    5959            # get a NotReady error 
    6060            self.assertRaises(cherrypy.NotReady, self.getPage, "/") 
     
    6666         
    6767        # Test server start 
    68         cherrypy.server.start(True, self.server_class) 
    69         self.assertEqual(cherrypy.server.state, 1) 
     68        cherrypy.server.start(self.server_class) 
     69        cherrypy.engine.start(blocking=False) 
     70        self.assertEqual(cherrypy.engine.state, 1) 
    7071         
    7172        if self.server_class: 
     
    8384        self.assertEqual(len(db_connection.threads), 1) 
    8485         
    85         # Test server stop 
    86         cherrypy.server.stop() 
    87         self.assertEqual(cherrypy.server.state, 0) 
    88          
    89         # Verify that the on_stop_server function was called 
     86        # Test engine stop 
     87        cherrypy.engine.stop() 
     88        self.assertEqual(cherrypy.engine.state, 0) 
     89         
     90        # Verify that the on_stop_engine function was called 
    9091        self.assertEqual(db_connection.running, False) 
    9192        self.assertEqual(len(db_connection.threads), 0) 
     
    101102            self.getPage("/") 
    102103            self.assertBody("Hello World") 
    103             cherrypy.server.stop() 
    104         cherrypy.server.start_with_callback(stoptest, server_class=self.server_class) 
    105         self.assertEqual(cherrypy.server.state, 0) 
     104            cherrypy.engine.stop() 
     105        cherrypy.engine.start_with_callback(stoptest) 
     106        self.assertEqual(cherrypy.engine.state, 0) 
     107        cherrypy.server.stop() 
    106108     
    107109    def test_1_Restart(self): 
    108         cherrypy.server.start(True, self.server_class) 
     110        cherrypy.server.start(self.server_class) 
     111        cherrypy.engine.start(blocking=False) 
    109112         
    110113        # The db_connection should be running now 
     
    117120         
    118121        # Test server restart from this thread 
    119         cherrypy.server.restart() 
    120         self.assertEqual(cherrypy.server.state, 1) 
     122        cherrypy.engine.restart() 
     123        self.assertEqual(cherrypy.engine.state, 1) 
    121124        self.getPage("/") 
    122125        self.assertBody("Hello World") 
     
    127130        # Test server restart from inside a page handler 
    128131        self.getPage("/restart") 
    129         self.assertEqual(cherrypy.server.state, 1) 
     132        self.assertEqual(cherrypy.engine.state, 1) 
    130133        self.assertBody("app was restarted succesfully") 
    131134        self.assertEqual(db_connection.running, True) 
     
    135138        self.assertEqual(len(db_connection.threads), 0) 
    136139         
     140        cherrypy.engine.stop() 
     141        self.assertEqual(cherrypy.engine.state, 0) 
     142        self.assertEqual(db_connection.running, False) 
     143        self.assertEqual(len(db_connection.threads), 0) 
    137144        cherrypy.server.stop() 
    138         self.assertEqual(cherrypy.server.state, 0) 
    139         self.assertEqual(db_connection.running, False) 
    140         self.assertEqual(len(db_connection.threads), 0) 
    141145     
    142146    def test_2_KeyboardInterrupt(self): 
     
    150154             
    151155            # We must start the server in this, the main thread 
    152             cherrypy.server.start(False, self.server_class) 
     156            cherrypy.server.start(self.server_class) 
    153157            # Time passes... 
    154             self.assertEqual(cherrypy.server.state, 0) 
    155158            self.assertEqual(db_connection.running, False) 
    156159            self.assertEqual(len(db_connection.threads), 0) 
     
    166169            threading.Thread(target=interrupt).start() 
    167170             
    168             cherrypy.server.start(False, self.server_class) 
     171            cherrypy.server.start(self.server_class) 
    169172            # Time passes... 
    170             self.assertEqual(cherrypy.server.state, 0) 
    171173            self.assertEqual(db_connection.running, False) 
    172174            self.assertEqual(len(db_connection.threads), 0) 
     
    182184        global db_connection 
    183185        db_connection = Dependency() 
    184         cherrypy.server.on_start_server_list.append(db_connection.start) 
    185         cherrypy.server.on_stop_server_list.append(db_connection.stop) 
    186         cherrypy.server.on_start_thread_list.append(db_connection.startthread) 
    187         cherrypy.server.on_stop_thread_list.append(db_connection.stopthread) 
     186        cherrypy.engine.on_start_engine_list.append(db_connection.start) 
     187        cherrypy.engine.on_stop_engine_list.append(db_connection.stop) 
     188        cherrypy.engine.on_start_thread_list.append(db_connection.startthread) 
     189        cherrypy.engine.on_stop_thread_list.append(db_connection.stopthread) 
    188190         
    189191        helper.CPTestRunner.run(suite) 
    190192    finally: 
    191193        cherrypy.server.stop() 
     194        cherrypy.engine.stop() 
    192195 
    193196 
  • trunk/cherrypy/tutorial/bonus-sqlobject.py

    r762 r1092  
    168168cherrypy.root = ContactManager() 
    169169cherrypy.server.start() 
     170cherrypy.engine.start() 
  • trunk/cherrypy/tutorial/tut01_helloworld.py

    r762 r1092  
    3232    # Start the CherryPy server. 
    3333    cherrypy.server.start() 
     34    cherrypy.engine.start() 
    3435 
  • trunk/cherrypy/tutorial/tut02_expose_methods.py

    r762 r1092  
    2525    cherrypy.config.update(file = 'tutorial.conf') 
    2626    cherrypy.server.start() 
     27    cherrypy.engine.start() 
    2728 
  • trunk/cherrypy/tutorial/tut03_get_and_post.py

    r762 r1092  
    4747    cherrypy.config.update(file = 'tutorial.conf') 
    4848    cherrypy.server.start() 
     49    cherrypy.engine.start() 
  • trunk/cherrypy/tutorial/tut04_complex_site.py

    r762 r1092  
    8888    cherrypy.config.update(file = 'tutorial.conf') 
    8989    cherrypy.server.start() 
     90    cherrypy.engine.start() 
    9091 
  • trunk/cherrypy/tutorial/tut05_derived_objects.py

    r762 r1092  
    7676    cherrypy.config.update(file = 'tutorial.conf') 
    7777    cherrypy.server.start() 
     78    cherrypy.engine.start() 
    7879 
  • trunk/cherrypy/tutorial/tut06_default_method.py

    r762 r1092  
    5757    cherrypy.config.update(file = 'tutorial.conf') 
    5858    cherrypy.server.start() 
     59    cherrypy.engine.start() 
    5960 
  • trunk/cherrypy/tutorial/tut07_sessions.py

    r1078 r1092  
    3434    cherrypy.config.update(file = 'tutorial.conf') 
    3535    cherrypy.server.start() 
     36    cherrypy.engine.start() 
    3637 
  • trunk/cherrypy/tutorial/tut08_generators_and_yield.py

    r762 r1092  
    3939    cherrypy.config.update(file = 'tutorial.conf') 
    4040    cherrypy.server.start() 
     41    cherrypy.engine.start() 
    4142 
  • trunk/cherrypy/tutorial/tut09_files.py

    r1070 r1092  
    9999    # Start the CherryPy server. 
    100100    cherrypy.server.start() 
     101    cherrypy.engine.start() 
  • trunk/cherrypy/tutorial/tut10_http_errors.py

    r856 r1092  
    7676    # Start the CherryPy server. 
    7777    cherrypy.server.start() 
     78    cherrypy.engine.start() 
  • trunk/cherrypy/tutorial/tutorial.conf

    r1078 r1092  
    33server.thread_pool = 10 
    44server.environment = "production" 
    5 # server.showTracebacks = True 
    6 # server.logToScreen = Fals
     5# server.show_tracebacks = True 
     6server.log_to_screen = Tru

Hosted by WebFaction

Log in as guest/cpguest to create tickets