You do not need to tune the listen() parameter to a greater number than 5.
The parameter determines how many not accept() -ed connections are allowed to be issued. The listen() parameter is not related to the number of simultaneously connected sockets, only to the number of simultaneous connections that were not an accept() -ed process.
If setting the parameter to listen() affects your code, this is a sign that there is too much delay between each call to accept() . Then you want to change your accept() loop so that it has less overhead.
In your case, I assume that self.q is a python queue , in which case you can call self.q.put_nowait() to avoid any possibility of blocking the accept() loop in this call.
Heath hunnicutt
source share