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

Check keys exist before delete in _StrKeyDict._update_expired_keys #118

Closed
wants to merge 3 commits into from

Conversation

mmcmahon-jana
Copy link

I was running into an issue when use fakeredis and freezegun to manipulate dates in a unit test. The _StrKeyDict._update_expired_keys was trying to delete keys that appeared the _ex_keys dict, but somehow the keys did not appear in the underlying _dict of the class instance.
This just updates the method to verify that the key is contained in the _ex_keys and _dict objects before calling del.

This method is called repeatedly while existing tests are run and I do not want to add a dependency on freezegun to recreate the circumstances of my specific bug. So I hope that this PR is ok without new tests.

I was running into an issue when use fakeredis and freezegun to manipulate dates in a unit test. The _StrKeyDict._update_expired_keys was trying to delete keys that appeared the _ex_keys dict, but somehow the keys did not appear in the underlying _dict of the class instance.
This just updates the method to verify that the key is contained in the _ex_keys and _dict objects before calling del.
…xpired_keys

Check keys before delete in  _update_expired_keys
@coveralls
Copy link

coveralls commented Jun 1, 2016

Coverage Status

Coverage increased (+0.004%) to 97.935% when pulling 1ffdc95 on mmcmahon-jana:master into c71157c on jamesls:master.

@kairichard
Copy link

@mmcmahon-jana are you using django-redis for session by any chance? Because then the problem is related to #120 as I experienced the same behavior as you did together with freezegun. A potential fix would be to call to_bytes when inserting keys into _ex_keys.

@mmcmahon-jana
Copy link
Author

@kairichard interesting, I'm not using django-redis but I will try the to_bytes fix you are suggesting to see if it makes a difference. Thanks.

@bmerry
Copy link
Collaborator

bmerry commented Nov 10, 2017

I've created a fork called fakenewsredis with a PyPI release to incorporate PRs that aren't getting traction here. I've included this #128 in fakenewsredis, which I think removes the need for this PR (but let me know if I've misunderstood the issue).

@bmerry
Copy link
Collaborator

bmerry commented Mar 22, 2018

Closing because the structure of the internal storage has changed in fakeredis 0.10.1, which should fix this issue.

@bmerry bmerry closed this Mar 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants