Commits

Robert Brewer  committed 7b3c8be

Another state test: restart within a page handler.

  • Participants
  • Parent commits a716511

Comments (0)

Files changed (1)

File cherrypy/test/test_states.py

     def ctrlc(self):
         raise KeyboardInterrupt()
     ctrlc.exposed = True
+    
+    def restart(self):
+        cherrypy.server.restart()
+        return "app was restarted succesfully"
+    restart.exposed = True
 
 cherrypy.root = Root()
 cherrypy.config.update({
         self.getPage("/")
         self.assertBody("Hello World")
         
-        # Test server restart
+        # Test server restart from this thread
         cherrypy.server.restart()
         self.assertEqual(cherrypy._appserver_state, 1)
         self.getPage("/")
         self.assertBody("Hello World")
         
+        # Test server restart from inside a page handler
+        self.getPage("/restart")
+        self.assertEqual(cherrypy._appserver_state, 1)
+        self.assertBody("app was restarted succesfully")
+        
         # Now that we've restarted, test a KeyboardInterrupt (ticket 321).
         if self.serverClass:
             cherrypy._httpserver.interrupt = KeyboardInterrupt
             self.assertRaises(cherrypy.NotReady, self.getPage, "/")
 
 
+
 def run(server, conf):
     helper.setConfig(conf)
     cherrypy._cputil._cpInitDefaultFilters()
     conf = {'server.socketHost': '127.0.0.1',
             'server.socketPort': 8000,
             'server.threadPool': 10,
-            'server.logToScreen': False,
+            'server.logToScreen': True,
             'server.logConfigOptions': False,
             'server.environment': "production",
             'server.showTracebacks': True,
         run(server, conf)
     _run(None)
     _run("cherrypy._cpwsgi.WSGIServer")
-    _run("cherrypy._cphttpserver.PooledThreadServer")
-    conf['server.threadPool'] = 1
-    _run("cherrypy._cphttpserver.CherryHTTPServer")
+##    _run("cherrypy._cphttpserver.PooledThreadServer")
+##    conf['server.threadPool'] = 1
+##    _run("cherrypy._cphttpserver.CherryHTTPServer")