![]() |
App Engine Python SDK
v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
|
Public Member Functions | |
def | __init__ |
def | start |
def | dispatch_port |
def | host |
def | dispatch_address |
def | quit |
def | modules |
def | get_hostname |
def | get_module_names |
def | get_module_by_name |
def | get_versions |
def | get_default_version |
def | add_event |
def | update_event |
def | set_num_instances |
def | get_num_instances |
def | start_version |
def | stop_version |
def | send_background_request |
def | add_async_request |
def | add_request |
def | __call__ |
A devappserver2 implementation of request_info.Dispatcher. In addition to the request_info.Dispatcher interface, it owns modules and manages their lifetimes.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.__init__ | ( | self, | |
configuration, | |||
host, | |||
port, | |||
auth_domain, | |||
runtime_stderr_loglevel, | |||
php_config, | |||
python_config, | |||
cloud_sql_config, | |||
vm_config, | |||
module_to_max_instances, | |||
use_mtime_file_watcher, | |||
automatic_restart, | |||
allow_skipped_files, | |||
module_to_threadsafe_override | |||
) |
Initializer for Dispatcher. Args: configuration: An application_configuration.ApplicationConfiguration instance storing the configuration data for the app. host: A string containing the host that any HTTP servers should bind to e.g. "localhost". port: An int specifying the first port where servers should listen. auth_domain: A string containing the auth domain to set in the environment variables. runtime_stderr_loglevel: An int reprenting the minimum logging level at which runtime log messages should be written to stderr. See devappserver2.py for possible values. php_config: A runtime_config_pb2.PhpConfig instances containing PHP runtime-specific configuration. If None then defaults are used. python_config: A runtime_config_pb2.PythonConfig instance containing Python runtime-specific configuration. If None then defaults are used. cloud_sql_config: A runtime_config_pb2.CloudSQL instance containing the required configuration for local Google Cloud SQL development. If None then Cloud SQL will not be available. vm_config: A runtime_config_pb2.VMConfig instance containing VM runtime-specific configuration. If vm_config does not have docker_daemon_url specified all docker-related stuff is disabled. module_to_max_instances: A mapping between a module name and the maximum number of instances that can be created (this overrides the settings found in the configuration argument) e.g. {'default': 10, 'backend': 15}. use_mtime_file_watcher: A bool containing whether to use mtime polling to monitor file changes even if other options are available on the current platform. automatic_restart: If True then instances will be restarted when a file or configuration change that effects them is detected. allow_skipped_files: If True then all files in the application's directory are readable, even if they appear in a static handler or "skip_files" directive. module_to_threadsafe_override: A mapping between the module name and what to override the module's YAML threadsafe configuration (so modules not named continue to use their YAML configuration).
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.add_async_request | ( | self, | |
method, | |||
relative_url, | |||
headers, | |||
body, | |||
source_ip, | |||
module_name = None , |
|||
version = None , |
|||
instance_id = None |
|||
) |
Dispatch an HTTP request asynchronously. Args: method: A str containing the HTTP method of the request. relative_url: A str containing path and query string of the request. headers: A list of (key, value) tuples where key and value are both str. body: A str containing the request body. source_ip: The source ip address for the request. module_name: An optional str containing the module name to service this request. If unset, the request will be dispatched to the default module. version: An optional str containing the version to service this request. If unset, the request will be dispatched to the default version. instance_id: An optional str containing the instance_id of the instance to service this request. If unset, the request will be dispatched to according to the load-balancing for the module and version.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.add_event | ( | self, | |
runnable, | |||
eta, | |||
service = None , |
|||
event_id = None |
|||
) |
Add a callable to be run at the specified time. Args: runnable: A callable object to call at the specified time. eta: An int containing the time to run the event, in seconds since the epoch. service: A str containing the name of the service that owns this event. This should be set if event_id is set. event_id: A str containing the id of the event. If set, this can be passed to update_event to change the time at which the event should run.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.add_request | ( | self, | |
method, | |||
relative_url, | |||
headers, | |||
body, | |||
source_ip, | |||
module_name = None , |
|||
version = None , |
|||
instance_id = None , |
|||
fake_login = False |
|||
) |
Process an HTTP request. Args: method: A str containing the HTTP method of the request. relative_url: A str containing path and query string of the request. headers: A list of (key, value) tuples where key and value are both str. body: A str containing the request body. source_ip: The source ip address for the request. module_name: An optional str containing the module name to service this request. If unset, the request will be dispatched according to the host header and relative_url. version: An optional str containing the version to service this request. If unset, the request will be dispatched according to the host header and relative_url. instance_id: An optional str containing the instance_id of the instance to service this request. If unset, the request will be dispatched according to the host header and relative_url and, if applicable, the load-balancing for the module and version. fake_login: A bool indicating whether login checks should be bypassed, i.e. "login: required" should be ignored for this request. Returns: A request_info.ResponseTuple containing the response information for the HTTP request.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.dispatch_address | ( | self | ) |
The address of the dispatch HTTP server e.g. "localhost:8080".
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.dispatch_port | ( | self | ) |
The port that the dispatch HTTP server for the Module is listening on.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.get_default_version | ( | self, | |
_module | |||
) |
Returns the default version for a module. Args: _module: A str containing the name of the module. Returns: A str containing the default version for the specified module. Raises: request_info.ModuleDoesNotExistError: The module does not exist.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.get_hostname | ( | self, | |
module_name, | |||
version, | |||
instance_id = None |
|||
) |
Returns the hostname for a (module, version, instance_id) tuple. If instance_id is set, this will return a hostname for that particular instances. Otherwise, it will return the hostname for load-balancing. Args: module_name: A str containing the name of the module. version: A str containing the version. instance_id: An optional str containing the instance ID. Returns: A str containing the hostname. Raises: request_info.ModuleDoesNotExistError: The module does not exist. request_info.VersionDoesNotExistError: The version does not exist. request_info.InvalidInstanceIdError: The instance ID is not valid for the module/version or the module/version uses automatic scaling.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.get_module_by_name | ( | self, | |
_module | |||
) |
Returns the module with the given name. Args: _module: A str containing the name of the module. Returns: The module.Module with the provided name. Raises: request_info.ModuleDoesNotExistError: The module does not exist.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.get_module_names | ( | self | ) |
Returns a list of module names.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.get_num_instances | ( | self, | |
module_name, | |||
version | |||
) |
Returns the number of instances running for a version of a module. Returns: An int containing the number of instances running for a module version. Args: module_name: A str containing the name of the module. version: A str containing the version. Raises: ModuleDoesNotExistError: The module does not exist. VersionDoesNotExistError: The version does not exist. NotSupportedWithAutoScalingError: The provided module/version uses automatic scaling.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.get_versions | ( | self, | |
_module | |||
) |
Returns a list of versions for a module. Args: _module: A str containing the name of the module. Returns: A list of str containing the versions for the specified module. Raises: request_info.ModuleDoesNotExistError: The module does not exist.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.host | ( | self | ) |
The host that the HTTP server for this Dispatcher is listening on.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.quit | ( | self | ) |
Quits all modules.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.send_background_request | ( | self, | |
module_name, | |||
version, | |||
inst, | |||
background_request_id | |||
) |
Dispatch a background thread request. Args: module_name: A str containing the module name to service this request. version: A str containing the version to service this request. inst: The instance to service this request. background_request_id: A str containing the unique background thread request identifier. Raises: NotSupportedWithAutoScalingError: The provided module/version uses automatic scaling. BackgroundThreadLimitReachedError: The instance is at its background thread capacity.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.set_num_instances | ( | self, | |
module_name, | |||
version, | |||
num_instances | |||
) |
Sets the number of instances to run for a version of a module. Args: module_name: A str containing the name of the module. version: A str containing the version. num_instances: An int containing the number of instances to run. Raises: ModuleDoesNotExistError: The module does not exist. VersionDoesNotExistError: The version does not exist. NotSupportedWithAutoScalingError: The provided module/version uses automatic scaling.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.start | ( | self, | |
api_host, | |||
api_port, | |||
request_data | |||
) |
Starts the configured modules. Args: api_host: The hostname that APIServer listens for RPC requests on. api_port: The port that APIServer listens for RPC requests on. request_data: A wsgi_request_info.WSGIRequestInfo that will be provided with request information for use by API stubs.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.start_version | ( | self, | |
module_name, | |||
version | |||
) |
Starts a version of a module. Args: module_name: A str containing the name of the module. version: A str containing the version. Raises: ModuleDoesNotExistError: The module does not exist. VersionDoesNotExistError: The version does not exist. NotSupportedWithAutoScalingError: The provided module/version uses automatic scaling.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.stop_version | ( | self, | |
module_name, | |||
version | |||
) |
Stops a version of a module. Args: module_name: A str containing the name of the module. version: A str containing the version. Raises: ModuleDoesNotExistError: The module does not exist. VersionDoesNotExistError: The version does not exist. NotSupportedWithAutoScalingError: The provided module/version uses automatic scaling.
def google.appengine.tools.devappserver2.dispatcher.Dispatcher.update_event | ( | self, | |
eta, | |||
service, | |||
event_id | |||
) |
Update the eta of a scheduled event. Args: eta: An int containing the time to run the event, in seconds since the epoch. service: A str containing the name of the service that owns this event. event_id: A str containing the id of the event to update.