-
Notifications
You must be signed in to change notification settings - Fork 840
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
Do not monkey-patch socket, ensure socketpair returns non-blocking sockets #918
Conversation
Codecov Report
@@ Coverage Diff @@
## master #918 +/- ##
==========================================
+ Coverage 81.52% 82.12% +0.59%
==========================================
Files 21 21
Lines 3789 3776 -13
Branches 563 560 -3
==========================================
+ Hits 3089 3101 +12
+ Misses 545 517 -28
- Partials 155 158 +3
Continue to review full report at Codecov.
|
@vitaly-krugl thanks for reviewing our recently merged PRs 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukebakken, thanks for picking this up. I added a couple of requests pertaining to the core changes. The auxiliary pika.compat.*
attribute accessor changes look good.
pika/compat/__init__.py
Outdated
finally: | ||
lsock.close() | ||
csock.setblocking(False) | ||
ssock.setblocking(False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My 2 cents: this function's name is exactly like the real deal in socket
module which returns blocking sockets; if some other part of pika or pika's user use it, they might expect that it behaves just like the one in socket
. For this reason, I would add the logic that makes the sockets non-blocking in the specialized method _get_interrupt_pair
augmented with a comment, such as "make sockets non-blocking to avoid potential deadlock".
pika/compat/__init__.py
Outdated
# We create a connected TCP socket. Note the trick with | ||
# setblocking(False) that prevents us from having to create a thread. | ||
lsock = socket.socket(family, type, proto) | ||
def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a function comment that explains the reasons for having this method - Windows doesn't provide socket.socketpair
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
# We create a connected TCP socket. Note the trick with | ||
# setblocking(False) that prevents us from having to create a thread. | ||
lsock = socket.socket(family, type, proto) | ||
def _nonblocking_socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@lukebakken - what's the story with |
@vitaly-krugl - I'm not sure. I think it has to do with test coverage specific to the changes in this PR. I'm not too concerned since everything else passes. What do you think? |
@lukebakken - Your call. I am the wrong person to ask, as I am a bit pedantic about such things :). |
Do not monkey-patch socket, ensure socketpair returns non-blocking sockets
Do not monkey-patch socket, ensure socketpair returns non-blocking sockets (cherry picked from commit 9cc3738)
Fixes #916
Fixes #917