Refactor: plain socket objects instead of wrapper classes#3454
Refactor: plain socket objects instead of wrapper classes#3454pajod wants to merge 10 commits intobenoitc:masterfrom
Conversation
Refactor socket creation to remove the socket wrapper classes so that these objects have less surprising behavior when used in worker hooks, worker classes, and custom applications. Rebased from benoitc#3127 Co-authored-by: Paul J. Dorn <pajod@users.noreply.github.com>
|
Whoops. There is no regression test for |
There was a problem hiding this comment.
Thanks for the refactor, code is cleaner :)
Few things to address:
ASGI Worker needs updating
The ASGI worker (gunicorn/workers/gasgi.py) still accesses sock.sock (line 181) and uses str(sock) for logging (line 187) - won't work with plain sockets.
listen() for fd-passed sockets
Old code called sock.listen(self.conf.backlog) including for systemd-passed fds. New set_socket_options() doesn't call it. Could this cause issues with systemd socket activation?
SSL validation timing
Changing to validate_file_exists at config time might break setups where certs are generated dynamically before start. Maybe keep runtime validation?
Tests
As you noted, need regression test for --enable-backlog-metric. Also missing tests for get_uri(), get_backlog(), set_socket_options().
Otherwise looks good - the close_sockets() error handling improvement is nice.
Copied the changes there, but did not check beyond running tests.
Right. I dont think it does anything, now that I dropped the
Fair point. Reverted.
I pushed some more unit tests (and the whole thing still passes my nginx test). I have one more commit to fix edge cases like Things I attempt to not touch here, but would like to follow up with:
|
|
I would be interested to receive clear confirmation from someone using the |
So, here is a rebased version with the fixup I commented earlier.