Package grassyknoll :: Package concurrent :: Module WhiskeyServer :: Class WhiskeyServer
[hide private]

Class WhiskeyServer

source code


a threadpool-based wsgi server.

Instance Methods [hide private]
 
__init__(self, host_port, num_workers, qsize, handler_class=WhiskeyRequestHandler, too_busy_content=default_too_busy_content)
host, port and handler_class are interpreted by WSGIServer.
source code
 
serve_forever(self)
Handle one request at a time until shutdown().
source code
 
shutdown(self)
stop the server
source code
 
install_signal_handler(self)
install a handler for SIGTERM, providing clean shutdown
source code
 
process_request_thread(self, request, client_address)
process a single request, in a Worker.Worker thread.
source code
 
process_request(self, request, client_address)
process incoming client requests.
source code
 
too_busy(self, request, client_address)
Called when the threadpool won't accept new requests.
source code
 
log_too_busy(self, remote_ip)
Called to log too_busy
source code
 
__make_too_busy_response(self, msg) source code
 
__format_simple_response(self, protocol, status, headers, content="")
Format a simple response for sending back to the client.
source code

Inherited from wsgiref.simple_server.WSGIServer: get_app, server_bind, set_app, setup_environ

Inherited from SocketServer.TCPServer: close_request, fileno, get_request, server_activate, server_close

Inherited from SocketServer.BaseServer: finish_request, handle_error, handle_request, verify_request

Class Variables [hide private]
  logger = AutoLogger()

Inherited from wsgiref.simple_server.WSGIServer: application

Inherited from BaseHTTPServer.HTTPServer: allow_reuse_address

Inherited from SocketServer.TCPServer: address_family, request_queue_size, socket_type

Instance Variables [hide private]
ThreadPool.ThreadPool threadpool
a threadpool to handle requests
Method Details [hide private]

__init__(self, host_port, num_workers, qsize, handler_class=WhiskeyRequestHandler, too_busy_content=default_too_busy_content)
(Constructor)

source code 

host, port and handler_class are interpreted by WSGIServer.

num_workers and qsize are interpreted by ThreadPool.ThreadPool
Parameters:
  • too_busy_content (str) - text/html content to send to browsers when the server is overloaded. This content is sent with a Status: 503 header and the connection is closed.
Overrides: SocketServer.TCPServer.__init__

serve_forever(self)

source code 
Handle one request at a time until shutdown().
Overrides: SocketServer.BaseServer.serve_forever

process_request_thread(self, request, client_address)

source code 

process a single request, in a Worker.Worker thread.

Derrived from SocketServer.ThreadingMixIn
Parameters:
  • request_client_address (tuple) - a handle to a client request. a 2-tuple of (socket, client_address).
Decorators:
  • @Wrappers.methodMessenger()

process_request(self, request, client_address)

source code 

process incoming client requests.

This method delivers the requests to the server's ThreadPool.ThreadPool to be serviced.

If the threadpool raises BoxFullError, call too_busy and allow the connection to be closed immediately.
Overrides: SocketServer.BaseServer.process_request

too_busy(self, request, client_address)

source code 

Called when the threadpool won't accept new requests.

This method sends too_busy_content to client with a Status: 503 header.

It also calls log_too_busy.

log_too_busy(self, remote_ip)

source code 

Called to log too_busy

Subclassers may override, but should run as quickly as possible, as your server is on fire.
Parameters:
  • remote_ip (string) - the IP address of the remote connection