fishy commented on a change in pull request #2200:
URL: https://github.com/apache/thrift/pull/2200#discussion_r464652291



##########
File path: lib/py/src/transport/TSocket.py
##########
@@ -91,12 +91,13 @@ def isOpen(self):
             try:
                 peeked_bytes = self.handle.recv(1, socket.MSG_PEEK)
             except (socket.error, OSError) as exc:  # on modern python this is 
just BlockingIOError
-                if exc.errno == errno.EWOULDBLOCK:
+                if exc.errno in (errno.EWOULDBLOCK, errno.EAGAIN):

Review comment:
       Would this cause trouble if `errno.EWOULDBLOCK` and `errno.EAGAIN` is 
the same thing? I assume it won't but just to double check here :)

##########
File path: lib/py/src/transport/TSocket.py
##########
@@ -91,12 +91,13 @@ def isOpen(self):
             try:
                 peeked_bytes = self.handle.recv(1, socket.MSG_PEEK)
             except (socket.error, OSError) as exc:  # on modern python this is 
just BlockingIOError
-                if exc.errno == errno.EWOULDBLOCK:
+                if exc.errno in (errno.EWOULDBLOCK, errno.EAGAIN):
                     return True
-                raise
+                return False

Review comment:
       I think we also need to catch exceptions that's not `socket.error` nor 
`OSError` to return False, so maybe it's better to have a catch-all on the 
upper level of try...finally to just `return False` for all exceptions? I know 
catch-all is usually discouraged in python linters but am not sure if there's a 
better approach here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to