You don't need to adjust the parameter to listen()
to a larger number than 5.
The parameter controls how many non-accept()
-ed connections are allowed to be outstanding. The listen()
parameter has no bearing on the number of concurrently connected sockets, only on the number of concurrent connections which have not been accept()
-ed by the process.
If adjusting the parameter to listen()
has an impact on your code, that is a symptom that too much delay occurs between each call to accept()
. You would then want to change your accept()
loop such that it has less overhead.
In your case, I am guessing that self.q
is a python queue, in which case you may want to call self.q.put_nowait()
to avoid any possibility of blocking the accept()
loop at this call.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…