| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files @@ Coverage Diff @@
## master #4089 +/- ##
===========================================
Coverage 100.00% 100.00%
===========================================
Files 540 409 -131
Lines 13969 10284 -3685
===========================================
- Hits 13969 10284 -3685 ☔ View full report in Codecov by Sentry. |
Sorry, something went wrong.
|
📝 Docs preview for commit 1c84c7b at: https://617463f634b44503a0606ef3--fastapi.netlify.app |
Sorry, something went wrong.
|
@tiangolo Could you please review this PR? It would my nice to fix this issue |
Sorry, something went wrong.
# Conflicts: # fastapi/dependencies/utils.py # tests/test_dependency_cache.py
Sorry, something went wrong.
There was a problem hiding this comment.
Can confirm that:
Sorry, something went wrong.
| solved = dependency_cache[sub_dependant.cache_key] | ||
|
|
||
| if sub_dependant.name is not None: | ||
| values[sub_dependant.name] = solved |
There was a problem hiding this comment.
| solved = dependency_cache[sub_dependant.cache_key] | |
| if sub_dependant.name is not None: | |
| values[sub_dependant.name] = solved | |
| if sub_dependant.name is not None: | |
| values[sub_dependant.name] = dependency_cache[sub_dependant.cache_key] |
Sorry, something went wrong.
| if dependency_cache is None: | ||
| dependency_cache = {} |
There was a problem hiding this comment.
Since we now use the same dependency_cache dict for all recursive calls, we can remove dependency_cache.update(sub_dependency_cache) line below, and get rid of sub_dependency_cache variable to make code cleaner:
(
sub_values,
sub_errors,
background_tasks,
_, # the subdependency returns the same response we have
sub_dependency_cache, # <== Change this line to "_,"
) = solved_result
dependency_cache.update(sub_dependency_cache) # <== Remove this line
Sorry, something went wrong.
|
@Kludex Any chase you can take a look?) |
Sorry, something went wrong.
| app = FastAPI() | ||
|
|
||
| counter_holder = {"counter": 0} | ||
| counter_holder = {"counter": 0, "parsing_counter": 0} |
There was a problem hiding this comment.
IMHO this should be set in pytest session-level context or similar, it shouldn't just be a global variable, I feel that there's too high a risk that the test could end up running with the counter initialised to a non-zero value (e.g. if for some reason the same test runs twice in one pytest invocation, if we end up adding another test in the future that depends on the same counter, etc).
Sorry, something went wrong.
|
Mentioning this perf improvement somewhere in the docs might also not be a bad idea? |
Sorry, something went wrong.
There was a problem hiding this comment.
Apologies for the late follow-up on this one.
PR #11323 has a very similar fix, and has been updated to include the unit test from this PR, and is in sync with current master. As such, I'm going to close this PR so we can hopefully wrap this up relatively quickly in #11323.
Thanks to everyone who contributed and helped review this one! If you have time, please consider having a quick look at #11323 as well. 🙏
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fix caching issue when instead of cache lookup dependency solving was performed all the time:
Code example:
Expected behaviour - parsing printed only one time
Actual behaviour - parsing printed two times