Skip to content
New issue

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

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

Already on GitHub? # to your account

Avoid 'Connection refused' when using gthread with keep-alive #1699

Merged
merged 1 commit into from
Mar 1, 2018

Conversation

ddzialak
Copy link
Contributor

@ddzialak ddzialak commented Feb 6, 2018

Fixes #1698

@benoitc
Copy link
Owner

benoitc commented Feb 6, 2018

Thanks for the patch! Looking :)

@ddzialak
Copy link
Contributor Author

ddzialak commented Feb 8, 2018

any update?

@ddzialak
Copy link
Contributor Author

ddzialak commented Feb 8, 2018

I've added two commits to make added attribute corresponding to it's name, these commits don't affect solution for connection refused problem. Now is_active should be True if it's processed and should not be present on self._keep and False if processing is done and should be present on self._keep. Please squash these commits if everything is ok.

Copy link
Collaborator

@tilgovi tilgovi left a comment

Choose a reason for hiding this comment

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

Does any of this get simpler to reason about or handle if the murder_keepalived method held the lock for the whole body of the loop? With the lock being taken in both branches of the if statement on line 168, I wonder whether it's worth the overhead of locking twice and whether holding the lock throughout might remove the race condition without introducing this new variable.

@ddzialak
Copy link
Contributor Author

@tilgovi That was my first try and after that received connection refused again but most probably I've done something wrong with testing..

@ddzialak
Copy link
Contributor Author

Now it's clean why moving whole murder_keepalived under lock doesn't solved that issue. Other important condition is that bug may happen only with Python2 because __cmp__ in python2 is used to override == operator while function __lt__ in Python3 doesn't.

@ddzialak
Copy link
Contributor Author

any update?

@benoitc benoitc merged commit 9c8695b into benoitc:master Mar 1, 2018
@benoitc
Copy link
Owner

benoitc commented Mar 1, 2018

Sorry for the delay. looks good, merging it now :) Thanks !

@ddzialak
Copy link
Contributor Author

ddzialak commented Mar 1, 2018 via email

@ddzialak
Copy link
Contributor Author

ddzialak commented Mar 7, 2018

@benoitc What is the estimated time when this change is pushed to PyPI?

mjjbell pushed a commit to mjjbell/gunicorn that referenced this pull request Mar 16, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants