def stopTurboGears(): """Handles TurboGears tasks when the CherryPy server stops. Ends all open database transactions, shuts down all extensions, calls user provided shutdown functions and stops the scheduler. """ # end all transactions and clear out the hubs to # help ensure proper reloading in autoreload situations for hub in hub_registry: hub.end() hub_registry.clear() stop_bonjour() # Shut down all TurboGears extensions extensions= pkg_resources.iter_entry_points( "turbogears.extensions" ) for entrypoint in extensions: try: ext = entrypoint.load() except Exception, e: log.exception("Error loading TurboGears extension plugin '%s': %s", entrypoint, e) continue if hasattr(ext, "shutdown_extension"): try: ext.shutdown_extension() except Exception, e: log.exception( "Error shutting down TurboGears extension '%s': %s", entrypoint, e)
def stopTurboGears(): # end all transactions and clear out the hubs to # help ensure proper reloading in autoreload situations for hub in hub_registry: hub.end() hub_registry.clear() stop_bonjour() # Shut down all TurboGears extensions extensions= pkg_resources.iter_entry_points( "turbogears.extensions" ) for entrypoint in extensions: ext= entrypoint.load() if hasattr(ext, "shutdown_extension"): ext.shutdown_extension() for item in call_on_shutdown: item() if config.get("tg.scheduler", False): scheduler._stop_scheduler() log.info("Scheduler stopped")