An abstract base class that implements some common functionality for the servers in gevent.
listener can either be an address that the server should bind on or a gevent.socket.socket instance that is already bound (and put into listening mode in case of TCP socket).
spawn, if provided, is called to create a new greenlet to run the handler. By default, gevent.spawn() is used.
Possible values for spawn:
IP address that the server is bound to (string).
Port that the server is bound to (an integer).
If the user initialized the server with an address rather than socket, then this function will create a socket, bind it and put it into listening mode.
It is not supposed to be called by the user, it is called by start() before starting the accept loop.
Start accepting the connections.
If an address was provided in the constructor, then also create a socket, bind it and put it into the listening mode.
Close the listener socket and stop accepting.
Stop accepting the connections and close the listening socket.
If the server uses a pool to spawn the requests, then stop() also waits for all the handlers to exit. If there are still handlers executing after timeout has expired (default 1 second), then the currently running handlers in the pool are killed.
Start the server if it hasn’t been already started and wait until it’s stopped.