Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use plain socket objects instead of wrapper classes #3127

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tilgovi
Copy link
Collaborator

@tilgovi tilgovi commented Dec 28, 2023

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.

Close #3013.

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.

Close #3013.
@jsprieto10
Copy link

is there anything else missing for this?

@tilgovi
Copy link
Collaborator Author

tilgovi commented Mar 5, 2024

@benoitc polite bump, if you have the time

if i < 5:
msg = "connection to {addr} failed: {error}"
log.debug(msg.format(addr=str(addr), error=str(e)))
log.error("Retrying in 1 second.")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pajod what's your idea there?

@benoitc
Copy link
Owner

benoitc commented Mar 6, 2024

@tilgovi is this ready for review or do yui think to any other addition/changes already?

@tnusser
Copy link

tnusser commented Apr 17, 2024

@tilgovi What is the status of your PR?

gunicorn/sock.py Outdated
# first initialization of gunicorn
old_umask = os.umask(conf.umask)
try:
for addr in [bind for bind in conf.address if not isinstance(bind, int)]:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make this part more readable. I would create the bind list in a separate line there.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does my PR work for you?

Copy link
Owner

@benoitc benoitc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tilgovi can you handle the change there. Otherwise I think it's OK for merge.

Implementing suggestion by reviewer #3127 (comment) to make code more readable.
@pajod
Copy link
Contributor

pajod commented May 20, 2024

Should the monkey patching in gunicorn/workers/ggevent.py stay the same?

I was able to run my WIP request after reloading test against your PR after fixing just the following variable access:

- sockets.append(socket.socket(s.FAMILY, socket.SOCK_STREAM,
-                                          fileno=s.sock.fileno()))
+ sockets.append(socket.socket(s.family, socket.SOCK_STREAM,
+                                          fileno=s.fileno()))

EDIT: rebased a24ff07 - including the above fix here:
master...pajod:gunicorn:patch-plain-socket

Update sock.py by making bind list creation more readable
rverelabs added a commit to rverelabs/gunicorn that referenced this pull request Sep 27, 2024
commit e4b5d48
Merge: a24ff07 ec52843
Author: Benoit Chesneau <bchesneau@gmail.com>
Date:   Sat Aug 10 10:23:20 2024 +0200

    Merge pull request benoitc#3188 from tnusser/patch-1

    Update sock.py by making bind list creation more readable

commit ec52843
Author: Tobias Nusser <tobiasnusser@web.de>
Date:   Wed Apr 17 12:48:26 2024 +0200

    Update sock.py by making bind list creation more readable

    Implementing suggestion by reviewer benoitc#3127 (comment) to make code more readable.

commit a24ff07
Author: Randall Leeds <randall@bleeds.info>
Date:   Thu Dec 28 00:57:50 2023 -0800

    Use plain socket objects instead of wrapper classes

    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.

    Close benoitc#3013.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad file descriptor problem still exists as of today with uvicorn workers
5 participants