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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change wait_on_entry_calc
to use while loop instead of recursion
#25
Conversation
Codecov Report
@@ Coverage Diff @@
## master #25 +/- ##
==========================================
- Coverage 95.67% 95.04% -0.64%
==========================================
Files 4 4
Lines 324 323 -1
Branches 30 30
==========================================
- Hits 310 307 -3
- Misses 8 9 +1
- Partials 6 7 +1
Continue to review full report at Codecov.
|
wait_on_entry_calc
to use while loop instead of recursionwait_on_entry_calc
to use while loop instead of recursion
Update on this: I can confirm that the updated cached function works as expected, even with this change made in the source. What would you advise in terms of testing and documentation? Happy to conform to your practices here. |
wait_on_entry_calc
to use while loop instead of recursionwait_on_entry_calc
to use while loop instead of recursion
This is awesome, @ericmjl ! I'll take a look at this soon. |
Well, for starters, the tests don't pass on Mac, so you should start with that: |
You can always see tests results on PRs here: |
I will take a look at the tests on macOS. That is surprising, I don't see much information available to debug:
Given your familiarity with the codebase, do you have a hypothesis as to what might be going on? |
@ericmjl I'll try and take a look soon |
Ok, I see that It's a VERY complicated test; I really can't remember it exactly, so this will require someone really digging in. |
Ok, I get it. All this code sets up a very specific scenario, that makes sure that So one thread calls a function and then deletes the cache, and second thread is called so it calls the same function and expects a cache entry and then gets the error. I don't remember/understand the exact setup now, when I look at the code, but we can make this happen. |
f9a3ea8
to
741cd33
Compare
To those who subscribed, shared a snippet for monkey-patching the fix: |
Released in |
@shaypal5 I'm submitting this PR to hopefully make cachier a bit more usable with long-running functions.
I had noticed that the recursion pattern in
wait_on_entry_calc
was causing the issues I was seeing in #24. I changed the implementation here, and ran a few test cases on a project I was working on.For short-running functions, nothing breaks. The cache gets loaded correctly, and the function executes correctly. For functions that are already cached, I made sure to use
overwrite_cache=True
to force overwriting of the cache.For long-running functions, the function just keeps on executing nicely until it finishes up and pickles down the result.I take this back - I am still measuring to see whether this code works properly.UPDATE 3:52 PM: I think this is working as expected. It's a long-running database query that we cache locally. I can see in pgadmin that the data are being pulled.
If you see that this is an erroneous PR, please let me know. Otherwise, please go to town with your critiques, and let me know what you'd like fixed up, I am happy to continue working on the PR till you're satisfied 馃槃.