Commits

Robert Brewer committed 220a120

Fixes to test_states.

  • Participants
  • Parent commits f6c1b1d

Comments (0)

Files changed (4)

cherrypy/_cpengine.py

     def block(self):
         """Block forever (wait for stop(), KeyboardInterrupt or SystemExit)."""
         try:
-            if self.autoreload_on:
-                i = 0
-                freq = self.autoreload_frequency
-            
             while self.state != STOPPED:
-                time.sleep(.1)
-                
-                # Autoreload
+                # Note that autoreload_frequency controls
+                # sleep timer even if autoreload is off.
+                time.sleep(self.autoreload_frequency)
                 if self.autoreload_on:
-                    i += .1
-                    if i > freq:
-                        i = 0
-                        self.autoreload()
+                    self.autoreload()
         except KeyboardInterrupt:
             cherrypy.log("<Ctrl-C> hit: shutting down app engine", "ENGINE")
             cherrypy.server.stop()
         if self.state == STARTED:
             for req, resp in self.servings:
                 resp.check_timeout()
-            freq = self.deadlock_poll_freq
-            self.monitor_thread = threading.Timer(freq, self.monitor)
-            self.monitor_thread.start()
+        freq = self.deadlock_poll_freq
+        self.monitor_thread = threading.Timer(freq, self.monitor)
+        self.monitor_thread.start()
     
     def start_with_callback(self, func, args=None, kwargs=None):
         """Start, then callback the given func in a new thread."""

cherrypy/_cprequest.py

                     cherrypy.response.finalize()
             finally:
                 self.hooks.run('on_end_resource')
-        except cherrypy.InternalRedirect:
+        except (KeyboardInterrupt, SystemExit, cherrypy.InternalRedirect):
             raise
         except:
             if self.throw_errors:

cherrypy/test/test_core.py

                "[Errno 2] No such file or directory: 'nonexistent.html'")
         self.assertInBody(msg)
         
-        # Ugly hack to skip the test if we're using _cpmodpy.
-        if cherrypy.servers.httpservers:
+        if (hasattr(self, 'harness') and
+            "modpython" in self.harness.__class__.__name__.lower()):
+            pass
+        else:
             # Test throw_errors (ticket #186).
             self.getPage("/error/rethrow")
             self.assertInBody("raise ValueError()")

cherrypy/test/test_states.py

 cherrypy.tree.mount(Root())
 cherrypy.config.update({
     'environment': 'test_suite',
-    'deadlock.poll_freq': 1,
-    'deadlock.timeout': 2,
+    'engine.deadlock_poll_freq': 1,
+    'response.timeout': 2,
     })
 
 class Dependency: