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
Several improvements to PubSub.parse_response() method. #707
Conversation
Previously, this case crashed in parse_response() with "AttributeError: 'NoneType' object has no attribute 'can_read'". This seems like an easy error to make -- at any rate, I keep making it -- so let's provide a clearer error message to save library users from digging into the source code to figure out what went wrong.
I found it confusing and hard to understand from the source code. And I'm pretty sure I found a bug: see test_parse_response() where I call parse_response with block=True. Yes, these tests need to be refactored. Coming in a future commit.
Now there is only one way to get indefinite blocking: pass timeout=None. Better, the bug I found in the last commit is fixed, because that way of asking for indefinite blocking no longer exists.
Ping...? @andymccurdy, I'd love some feedback on this. I think it's a nice little cleanup, but I can see how a reasonable person might object to certain aspects of the PR. Would like to hear what you think! (More importantly, I also want to know if I can rely on |
Hi @gward the PR seems rationale, with your changes the parameters regarding the timeout are aligned with well reputed specifications [1] and clearly most known used. IMHO I would keep the About the tests, for me they are a bit fragile and hard to keep them deterministic - tried to contain with a I would suggest rewrite these tests taking into account this situation, getting just those tests that are deterministic and maintainable, perhaps How does it look for you? [1] http://linux.die.net/man/2/select |
@pfreixes thank you for the feedback! I'm leaving for 10 days of vacation soon, so won't be able to handle everything right now. But your changes to I need to spend some time thinking about the tests. I really want to retain the test that reproduces the bug I found. Apart from that, I'm open to suggestions. I have no idea how to test network-timing-dependent code without fuzzy comparisons and without some degree of non-determinism. If you can point out existing tests in redis-py that do this, I will read them carefully to learn how it's done. |
Hi @gward, regarding the bug and its test that its related with #716 I would suggest send a MR detached from the current one to make it mergeable easily and properly related with the issue already opened, @andymccurdy will appreciate it. About the tests, remember that integration tests are not unit test and the test pyramid principle [1] says that the cases covered by integration or acceptance test are just those ones related with the user feature. IMHO I will keep them as much simple as it possible. Im still convinced that we should cover the |
@gward I didn't understand the bug you refer to just be looking at it. Could you explain? (Sorry if I'm being slow.) |
This pull request is marked stale. It will be closed in 30 days if it is not updated. |
In trying to understand blocking/timeout semantics, I think I found an easier way to do things, and I found a bug.