def _handle_deferred_gc(self, ref, request): """ This function is called when the request_proxy in the baton have been finalized. """ # if the client haven't gotten a response, just finish the request log.debug("Garbage collecting for request: %s" % request) if not request.finished and request.channel: request.finish() self._weakrefs.remove(ref)
def is_client_allowed_debugging(self, request): """ Checks with the debugging configuration if the client responsible for the request is allowed to perform debugging. """ client_names = [request.getClient(), request.getClientIP()] for client_name in client_names: if client_name in self.allow: return True formatted_client_name = " or ".join(['"%s"' % client_name for client_name in list(set(client_names))]) log.debug( "A client identified by %s attempted to access a debugging resource, but was denied." % formatted_client_name ) return False
def _test_connection_until_working(self): """ Keep trying to connect. Calls itself every `wait_between_reconnect_tries` seconds. """ while self.running: try: log.debug('Trying to connect to database "%s"' % self.database_name) yield threads.deferToThread(self.test_connectivity) yield threads.deferToThread(self.reconnected) break except sa.exc.SQLAlchemyError, e: reactor.callFromThread(self.on_connection_failed, failure.Failure()) log.error('Could not connect to database "%s": %s' % (self.database_name, e)) yield util.wait(self.reconnect_wait)
def load_from_file(self, filename): """ Load the configuration by parsing the data in the given file. For an overview of how configuration is loaded, see :doc:`/topic/configuration` """ filename = util.expand_filepath(filename) log.debug('Loading configuration from: %s'%filename) self._fail_if_configuration_file_does_not_exist(filename) base_config = yaml.load(open(filename)) complete_config = self._load_config(base_config, [filename]) self._resolve_aliases(complete_config) self._config = complete_config log.debug('Loaded configuration: '+pformat(complete_config))
def configure(self, runtime_environment): routing = self.site_configuration["routing"] if self.debug_configuration: log.debug('Debugging enabled for site "%s": %s.' % (self.site_name, self.debug_configuration)) if not self.debug_configuration["allow"]: log.warn('No clients are currently allowed to debug on site "%s".' % self.site_name) root_resource = WebResource(self, routing) root_resource.configure(runtime_environment) self.factory = server.Site(root_resource) self.factory.displayTracebacks = bool(self.debug_configuration) self.tcpserver = internet.TCPServer(self.site_configuration.get("port", 8080), self.factory) self.tcpserver.setServiceParent(self)
def _warn_because_file_is_loaded_multiple_times(path, visited_files): msg = 'configuration file loaded multiple times: "%s"' % path detail = ('During the handling of configuration file includes, ' 'a previously included file was encountered.') existing_files = [file for file in visited_files if os.path.exists(file)] hint = ('Ensure that the "includes" do not accidentally recurse. ' 'Visited files in the following order:\n ' + '\n\n * '.join(existing_files)) # issue a simple warning, log more details with hints: warnings.warn(exceptions.ConfigurationWarning(msg)) log.debug('WARNING: %s' % msg) log.debug('DETAIL: %s' % detail) log.debug('HINT: %s' % hint)
def lineReceived(self, line): baton = dict(line=line) if not self.pipeline_name: log.debug('Output from process %s on %s ignored because no pipeline were configured. Output was: %s.'%(self.process_protocol.process_name, self.type, line)) else: self.deferred_queue.put(baton)