-
Notifications
You must be signed in to change notification settings - Fork 240
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
Catch Connection Error when redis isn't up #22 #24
Conversation
@@ -21,15 +23,27 @@ | |||
'hour': 3600 | |||
} | |||
|
|||
def check_redis_alive(force_exit = 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.
I believe PEP8 style says no spaces around the =
.
Thanks, this is helpful! Three small bits of feedback:
(I think the answer to (2) is "no" but wanted to make sure.) |
- setup.py removed empty line flake8 was complaining.
|
try: | ||
redis_client.ping() | ||
except ConnectionError as e: | ||
print(e) |
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.
Nice, how about also printing a friendly error message? I'm debating if we need only a pretty error message like "Failed to connect to redis"
.
I don't mind using message + stacktrace, but let's make it user friendly.
Awesome! Thanks for making the change @voidpirate I also had some minor suggestions in the comments. Please address before merge
Won't block merge
@jparise the reason I put the testing in the optional here is that I think we should actually mock the redis server entirely. I created an issue |
redis_client.ping() | ||
except ConnectionError as e: | ||
print(e) | ||
if fn.__name__ == "main": |
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.
Minor nit: can we switch this to single quotes? I haven't done it yet, but I am going to write a coding style for this repo, and strings favor single quotes if possible.
- Call function within try/catch - Syntax clean up
Kicked the travis job back, and it's now successful. |
This handles the
ConnectionError
both when starting the server and if the redis server goes away during the request lifecycle.