Documentation for pulsar's DEVELOPMENT version. Get the release docs here.
This is the most important pulsar application. The server is a specialized socket server for web applications conforming with the python web server gateway interface (WSGI 1.0.1). The server can be used in conjunction with several web frameworks as well as pulsar wsgi application handlers, pulsar router, the pulsar RPC middleware and the websocket middleware.
Pulsar wsgi server is production ready designed to easily handle fast, scalable http applications. As all pulsar applications, it uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. In addition, its multiprocessing capabilities allow to handle the c10k problem with ease.
An example of a web server written with pulsar.apps.wsgi which responds with Hello World! for every request:
from pulsar.apps import wsgi def hello(environ, start_response): data = b"Hello World!" response_headers = [('Content-type','text/plain'), ('Content-Length', str(len(data)))] start_response("200 OK", response_headers) return [data] if __name__ == '__main__': wsgi.WSGIServer(hello).start()
For more information regarding WSGI check the pep3333 specification. To run the application:
For available run options:
python script.py --help
Server side WSGI ProtocolConsumer.
The wsgi callable handling requests.
Implements data_received() method.
Once we have a full HTTP message, build the wsgi environ and delegate the response to the wsgi_callable() function.
WSGI compliant start_response callable, see pep3333.
The application may call start_response more than once, if and only if the exc_info argument is provided. More precisely, it is a fatal error to call start_response without the exc_info argument if start_response has already been called within the current invocation of the application.
The write() method.
HOP_HEADERS are not considered but no error is raised.
The write function returned by the start_response() method.
Required by the WSGI specification.
Check if the response uses chunked transfer encoding.
Only use chunked responses when the client is speaking HTTP/1.1 or newer and there was no Content-Length header set.
Get the headers to send to the client.
An function to create a WSGI environment dictionary for testing.
a secure connection?
a valid WSGI environ dictionary.