Uh oh!
There was an error while loading. Please reload this page.
Pause server - #448
Conversation
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.
Fix Server create for unix sockets and add support for max_connections.
1st1
commented
Oct 19, 2016
We'll need tests for this new functionality. I think that |
mayfield
commented
Oct 19, 2016
@1st1 |
1st1
commented
Oct 19, 2016
But what criteria do you use to pick up a sound number for |
mayfield
commented
Oct 19, 2016
I'd expect it to be mostly application dependant. It would obviously need to be less than the In my particular case setting |
mayfield
commented
Oct 19, 2016
I'm writing some tests btw, but before I get too far, are you generally okay with the location of the functionality and the way the start_serving arguments are stored in |
1st1
commented
Oct 19, 2016
I think that the way the patch is stuctured now is fine. But before you get too far, let's wait until @gvanrossum gives this idea a green light. |
Tests for create_server(max_connections=number) and Server.pause/resume.
Refactored a bit to share most the logic with the TCP server.
mayfield
commented
Nov 3, 2016
Should I be evangelizing this? I'd like to see it get accepted. @gvanrossum has publicly stated he's not focused on asyncio as much as he used to be, so perhaps there are other stakeholders we can bother? |
1st1
commented
Nov 4, 2016
@gvanrossum What do you think on this one? 3.7? |
gvanrossum
commented
Nov 4, 2016
Definitely 3.7. Until then this could easily be implemented as a separate AbstractServer subclass. |
mayfield
commented
Nov 4, 2016
3.7 is fine, let me know how I can help or what I should do, if anything. Re: subclassing AbstractServer, I believe I brought this up in the forum in the context of allowing a user to bring their own Server subclass to |
1st1
commented
Nov 4, 2016
@gvanrossum This is something we can still do in 3.6, right? IIUC we can add a |
gvanrossum
commented
Nov 4, 2016
via email
For something meant to go into the stdlib at 3.7, copypasta is probaby not
a problem. |
1st1
commented
Mar 2, 2017
Please reopen this PR at https://github.com/python/cpython. This repo is going to be deleted soon. |
Re: https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!topic/python-tulip/btGHbh5kUUM
Tests pass. I sort of wish the pause and resume functions could elegantly live on the event loop and not on the Server object, but it seems to be the best contextual storage for all the listening sockets.
Also I'm not sure max_connections on create_server is justifiable or even a good name, but it was immediately useful to my particular problem and I imagine it could be to others too. So I left it in.