Pause server by mayfield · Pull Request #448 · python/asyncio

@mayfield

Add a `pause`/`resume` API to `Server` which removes/adds a server's
listening sockets on its event loop selector.  This facility allows DoS
prevention from SYN flooding connection herds.

Add `max_connections` kwarg to `loop.create_server` and `Server` which
controls pause/resume behavior when not `None`.

Notes:

  1. Using Server.pause/resume and create_server(max_connections) are
     mutually exclusive.
  2. The listen backlog and accept semantics are not taken into consideration.
     As a result the actual number of connections established will vary
     and should be considered platform and/or event loop dependant.