Changeset 1989
- Timestamp:
- 06/24/08 00:18:26
- Files:
-
- trunk/cherrypy/__init__.py (modified) (3 diffs)
- trunk/cherrypy/_cpconfig.py (modified) (1 diff)
- trunk/cherrypy/_cpmodpy.py (modified) (3 diffs)
- trunk/cherrypy/_cptree.py (modified) (2 diffs)
- trunk/cherrypy/cherryd (modified) (1 diff)
- trunk/cherrypy/process/plugins.py (modified) (1 diff)
- trunk/cherrypy/process/win32.py (modified) (3 diffs)
- trunk/cherrypy/process/wspbus.py (modified) (1 diff)
- trunk/cherrypy/test/helper.py (modified) (1 diff)
- trunk/cherrypy/test/test_states.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/__init__.py
r1961 r1989 175 175 from cherrypy.process import win32 176 176 engine = win32.Win32Bus() 177 _console_control_handler = win32.ConsoleCtrlHandler(engine) 178 # If you don't want a ConsoleControlHandler, 179 # unsubscribe this before calling engine.start(). 180 _console_control_handler.subscribe() 177 engine.console_control_handler = win32.ConsoleCtrlHandler(engine) 181 178 del win32 182 179 except ImportError: … … 204 201 for req, resp in self.servings: 205 202 resp.check_timeout() 206 timeout_monitor = _TimeoutMonitor(engine) 207 timeout_monitor.subscribe() 208 209 # Add an autoreloader (the 'engine' config namespace may detach/attach it). 203 engine.timeout_monitor = _TimeoutMonitor(engine) 204 engine.timeout_monitor.subscribe() 205 210 206 engine.autoreload = process.plugins.Autoreloader(engine) 211 207 engine.autoreload.subscribe() 212 208 213 process.plugins.ThreadManager(engine).subscribe() 214 215 signal_handler = process.plugins.SignalHandler(engine) 209 engine.thread_manager = process.plugins.ThreadManager(engine) 210 engine.thread_manager.subscribe() 211 212 engine.signal_handler = process.plugins.SignalHandler(engine) 213 216 214 217 215 from cherrypy import _cpserver … … 243 241 tree.mount(root, script_name, config) 244 242 245 signal_handler.subscribe() 243 if hasattr(engine, "signal_handler"): 244 engine.signal_handler.subscribe() 245 if hasattr(engine, "console_control_handler"): 246 engine.console_control_handler.subscribe() 247 246 248 engine.start() 247 249 engine.block() trunk/cherrypy/_cpconfig.py
r1930 r1989 306 306 engine.autoreload.files = v 307 307 elif k == 'deadlock_poll_freq': 308 cherrypy.timeout_monitor.frequency = v308 engine.timeout_monitor.frequency = v 309 309 elif k == 'SIGHUP': 310 310 engine.listeners['SIGHUP'] = set([v]) trunk/cherrypy/_cpmodpy.py
r1982 r1989 22 22 'log.screen': False, 23 23 'show_tracebacks': False}) 24 25 # Turn off the builtin signal handlers, which can interact26 # in strange ways with the Apache process.27 cherrypy.engine.SIGHUP = None28 cherrypy.engine.SIGTERM = None29 30 # You must start the engine in a non-blocking fashion31 # so that mod_python can proceed32 cherrypy.engine.start()33 24 34 25 ########################################## … … 98 89 }) 99 90 100 if hasattr(cherrypy, '_console_control_handler'): 101 cherrypy._console_control_handler.unsubscribe() 102 cherrypy.engine.autoreload.unsubscribe() 91 engine = cherrypy.engine 92 if hasattr(engine, "signal_handler"): 93 engine.signal_handler.unsubscribe() 94 if hasattr(engine, "console_control_handler"): 95 engine.console_control_handler.unsubscribe() 96 engine.autoreload.unsubscribe() 103 97 cherrypy.server.unsubscribe() 104 98 … … 115 109 # Also, "When server is not specified...LogLevel does not apply..." 116 110 apache.log_error(msg, newlevel, req.server) 117 cherrypy.engine.subscribe('log', _log)118 119 cherrypy.engine.start()111 engine.subscribe('log', _log) 112 113 engine.start() 120 114 121 115 def cherrypy_cleanup(data): 122 cherrypy.engine.exit()116 engine.exit() 123 117 try: 124 118 # apache.register_cleanup wasn't available until 3.1.4. trunk/cherrypy/_cptree.py
r1938 r1989 109 109 resp = self.response_class() 110 110 cherrypy.serving.load(req, resp) 111 cherrypy. timeout_monitor.acquire()111 cherrypy.engine.timeout_monitor.acquire() 112 112 cherrypy.engine.publish('acquire_thread') 113 113 … … 118 118 req = cherrypy.serving.request 119 119 120 cherrypy. timeout_monitor.release()120 cherrypy.engine.timeout_monitor.release() 121 121 122 122 try: trunk/cherrypy/cherryd
r1987 r1989 26 26 plugins.PIDFile(engine, pidfile).subscribe() 27 27 28 cherrypy.signal_handler.subscribe() 28 if hasattr(engine, "signal_handler"): 29 engine.signal_handler.subscribe() 30 if hasattr(engine, "console_control_handler"): 31 engine.console_control_handler.subscribe() 29 32 30 33 if fastcgi: trunk/cherrypy/process/plugins.py
r1938 r1989 361 361 self.thread.setName(threadname) 362 362 self.thread.start() 363 self.bus.log("Started thread %r." % threadname)363 self.bus.log("Started monitor thread %r." % threadname) 364 364 else: 365 self.bus.log(" Thread %r already started." % threadname)365 self.bus.log("Monitor thread %r already started." % threadname) 366 366 start.priority = 70 367 367 trunk/cherrypy/process/win32.py
r1938 r1989 21 21 def start(self): 22 22 if self.is_set: 23 self.bus.log('Handler for console events already set.', level=40) 23 24 return 24 25 … … 28 29 win32api.GetLastError(), level=40) 29 30 else: 31 self.bus.log('Set handler for console events.', level=40) 30 32 self.is_set = True 31 33 32 34 def stop(self): 33 35 if not self.is_set: 36 self.bus.log('Handler for console events already off.', level=40) 34 37 return 35 38 … … 44 47 win32api.GetLastError(), level=40) 45 48 else: 49 self.bus.log('Removed handler for console events.', level=40) 46 50 self.is_set = False 47 51 trunk/cherrypy/process/wspbus.py
r1938 r1989 201 201 self.log('Bus EXITING') 202 202 self.publish('exit') 203 # This isn't strictly necessary, but it's better than seeing 204 # "Waiting for child threads to terminate..." and then nothing. 205 self.log('Bus EXITED') 203 206 204 207 def restart(self): trunk/cherrypy/test/helper.py
r1867 r1989 110 110 cherrypy.config.reset() 111 111 setConfig(conf) 112 cherrypy.signal_handler.subscribe() 112 engine = cherrypy.engine 113 if hasattr(engine, "signal_handler"): 114 engine.signal_handler.subscribe() 115 if hasattr(engine, "console_control_handler"): 116 engine.console_control_handler.subscribe() 113 117 # The Pybots automatic testing system needs the suite to exit 114 118 # with a non-zero value if there were any problems. 115 119 # Might as well stick it in the engine... :/ 116 cherrypy.engine.test_success = True117 cherrypy.engine.start_with_callback(_run_test_suite_thread,118 args=(moduleNames, conf))119 cherrypy.engine.block()120 if cherrypy.engine.test_success:120 engine.test_success = True 121 engine.start_with_callback(_run_test_suite_thread, 122 args=(moduleNames, conf)) 123 engine.block() 124 if engine.test_success: 121 125 return 0 122 126 else: trunk/cherrypy/test/test_states.py
r1870 r1989 230 230 cherrypy.server.start() 231 231 try: 232 self.assertNotEqual( cherrypy.timeout_monitor.thread, None)232 self.assertNotEqual(engine.timeout_monitor.thread, None) 233 233 234 234 # Request a "normal" page. 235 self.assertEqual( cherrypy.timeout_monitor.servings, [])235 self.assertEqual(engine.timeout_monitor.servings, []) 236 236 self.getPage("/") 237 237 self.assertBody("Hello World") 238 238 # request.close is called async. 239 while cherrypy.timeout_monitor.servings:239 while engine.timeout_monitor.servings: 240 240 print ".", 241 241 time.sleep(0.01)

