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

Replace OSError exceptions from can_read with redis.ConnectionError #2140

Merged
merged 3 commits into from
May 8, 2022

Conversation

kristjanvalur
Copy link
Contributor

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

This change catches OS errors in Connection.can_read, closes connection and raises a redis.ConnectionError.
Fixes #2138

@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2022

Codecov Report

Merging #2140 (1087770) into master (6ba4641) will increase coverage by 0.00%.
The diff coverage is 60.00%.

@@           Coverage Diff           @@
##           master    #2140   +/-   ##
=======================================
  Coverage   92.44%   92.44%           
=======================================
  Files         104      104           
  Lines       24385    24393    +8     
=======================================
+ Hits        22542    22550    +8     
  Misses       1843     1843           
Impacted Files Coverage Δ
redis/asyncio/connection.py 84.56% <60.00%> (-0.17%) ⬇️
redis/connection.py 86.36% <60.00%> (-0.18%) ⬇️
tests/test_cluster.py 97.60% <0.00%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ba4641...1087770. Read the comment docs.

@chayim
Copy link
Contributor

chayim commented Apr 27, 2022

@kristjanvalur I tried to push an update to your branch, to fix the linters. Can you run the following to fix your linting? Then we can merge!

black redis

except OSError as e:
await self.disconnect()
raise ConnectionError(
f"Error while reading from {self.host}:{self.port} : {e.args}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. Small nit to remove a space.

                f"Error while reading from {self.host}:{self.port}: {e.args}"

return self._parser.can_read(timeout)
except OSError as e:
self.disconnect()
raise ConnectionError(f"Error while reading from {self.host}:{self.port} : {e.args}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

                f"Error while reading from {self.host}:{self.port}: {e.args}"

Copy link
Contributor

@chayim chayim left a comment

Choose a reason for hiding this comment

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

Ready to merge pending the lint fix, and this small change!

@chayim chayim added the breakingchange API or Breaking Change label May 3, 2022
@chayim chayim self-requested a review May 8, 2022 12:01
@dvora-h dvora-h merged commit c25be04 into redis:master May 8, 2022
@kristjanvalur kristjanvalur deleted the pr-can_read branch May 9, 2022 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakingchange API or Breaking Change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

connection.can_read() raises OSError when connection is broken
4 participants