Skip to content
module

htcollector.Server

Classes
  • InterceptorHandlerFactory Provides a single handler that returns an InterceptorHandler(BaseHTTPRequestHandler) that writes measurements to the provided MeasurementDatabase.</>
  • Interceptor Mix-in class to handle each request in a new thread.</>
class

htcollector.Server.InterceptorHandlerFactory()

Provides a single handler that returns an InterceptorHandler(BaseHTTPRequestHandler) that writes measurements to the provided MeasurementDatabase.

class

htcollector.Server.Interceptor(server_address, db, static_directory)

Bases
http.server.ThreadingHTTPServer socketserver.ThreadingMixIn http.server.HTTPServer socketserver.TCPServer socketserver.BaseServer

Mix-in class to handle each request in a new thread.

Methods
method

serve_forever(poll_interval=0.5)

Handle one request at a time until shutdown.

Polls for shutdown every poll_interval seconds. Ignores self.timeout. If you need to do periodic tasks, do them in another thread.

method

shutdown()

Stops the serve_forever loop.

Blocks until the loop has finished. This must be called while serve_forever() is running in another thread, or it will deadlock.

method

service_actions()

Called by the serve_forever() loop.

May be overridden by a subclass / Mixin to implement any code that needs to be run during the loop.

method

handle_request()

Handle one request, possibly blocking.

Respects self.timeout.

method

handle_timeout()

Called if no new request arrives within self.timeout.

Overridden by ForkingMixIn.

method

verify_request(request, client_address)

Verify the request. May be overridden.

Return True if we should proceed with this request.

method

finish_request(request, client_address)

Finish one request by instantiating RequestHandlerClass.

method

handle_error(request, client_address)

Handle an error gracefully. May be overridden.

The default is to print a traceback and continue.

method

server_activate()

Called by constructor to activate the server.

May be overridden.

method

fileno()

Return socket file number.

Interface required by selector.

method

get_request()

Get the request and client address from the socket.

May be overridden.

method

shutdown_request(request)

Called to shutdown and close an individual request.

method

close_request(request)

Called to clean up an individual request.

method

process_request_thread(request, client_address)

Same as in BaseServer but as a thread.

In addition, exception handling is done here.

method

process_request(request, client_address)

Start a new thread to process the request.

method

server_bind()

Override server_bind to store the server name.