Force gevent connected socket to blocking mode #1616
Merged
Conversation
Thank you for providing such detailed information and a patch. The patch is simple and it sounds like it would work, but do you think that the assumption Gunicorn makes about the socket being blocking is a bad one? Should we discuss any alternative changes? |
I was also concerned about that but came to the conclusion its probably ok. This gets a bit confusing since we are talking about blocking sockets that in the gevent world aren't necessarily really blocking anything. My thoughts:
|
Thanks for all that analysis. I agree with you. It does sound like it would fix #880, too. At least one comment there suggests that changing the socket timeout fixed the problem. |
61431d4
into
benoitc:master
1 of 8 checks passed
1 of 8 checks passed
endreymarcell
added a commit
to prezi/gunicorn
that referenced
this pull request
Jan 3, 2018
mjjbell
pushed a commit
to mjjbell/gunicorn
that referenced
this pull request
Mar 16, 2018
…ed-socket Force gevent connected socket to blocking mode
Open
sokac
added a commit
to sokac/thrift
that referenced
this pull request
Apr 27, 2018
Timeout is already set in HttpClient. The reason for removal is issue with gunicorn and gevent as described here benoitc/gunicorn#1616
sokac
added a commit
to sokac/thrift
that referenced
this pull request
Apr 27, 2018
Timeout is already set in HttpClient. The reason for removal is issue with gunicorn and gevent as described here benoitc/gunicorn#1616
jeking3
added a commit
to apache/thrift
that referenced
this pull request
May 7, 2018
Timeout is already set in HttpClient. The reason for removal is issue with gunicorn and gevent as described here benoitc/gunicorn#1616
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
The gevent worker assumes sockets are running in blocking mode. The current code forces the listening socket into blocking mode here. But the connected socket is not forced to blocking mode. Therefore if other code has set the default socket timeout with a call to
setdefaulttimeout
it will be set as the connected socket's timeout in the gevent initialization code here.The gevent worker relies on the keepalive timeout to close idle connections. Setting the default timeout below the keepalive timeout causes the worker to run in a undefined mode. I believe this may fix the issues in #880 but it was not clear if everyone having that issue were also calling
setdefaulttimeout
. In our particular case we are callingsetdefaulttimeout
which caused sockets to close before the keepalive expired. This causes a bunch of socket timeout error messages and potentially 504 errors with AWS ELBs.