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

BlockingConnection._handle_timeout() logic error #411

Closed
vitaly-krugl opened this issue Oct 28, 2013 · 1 comment
Closed

BlockingConnection._handle_timeout() logic error #411

vitaly-krugl opened this issue Oct 28, 2013 · 1 comment

Comments

@vitaly-krugl
Copy link
Member

This block of code doesn't make sense:

        if self.is_closing and self._socket_timeouts > threshold:
            if not self.is_closing:
                LOGGER.critical('Closing connection due to timeout')
            self._on_connection_closed(None, True)

if if self.is_closing and self._socket_timeouts > threshold is true, then the inner if not self.is_closing can never be true. Did the author intend the outer check to be if self.is_closing or self._socket_timeouts > threshold instead (or vs. and)?

Here is the entire method for context:

    def _handle_timeout(self):
        """Invoked whenever the socket times out"""
        self._socket_timeouts += 1
        threshold = (self.SOCKET_TIMEOUT_THRESHOLD if not self.is_closing else
                     self.SOCKET_TIMEOUT_CLOSE_THRESHOLD)

        LOGGER.debug('Handling timeout %i with a threshold of %i',
                     self._socket_timeouts, threshold)
        if self.is_closing and self._socket_timeouts > threshold:
            if not self.is_closing:
                LOGGER.critical('Closing connection due to timeout')
            self._on_connection_closed(None, True)
@vitaly-krugl
Copy link
Member Author

Fixed via PR #533

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

No branches or pull requests

2 participants