Opened 4 weeks ago
Last modified 4 weeks ago
#36967 assigned Cleanup/optimization
Use graphlib's TopologicalSorter to handle circular imports similar to migrations
| Reported by: | blighj | Owned by: | blighj |
|---|---|---|---|
| Component: | contrib.staticfiles | Version: | 6.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When ManifestStaticFilesStorage post processes files, it handles dependency chains by looping until it sees no more changes in the files.
If there is a circular loop it will only try for 5 cycles by default and then throw an error. This can be changed with the max_post_process_passes attribute.
I propose we replace the looping approach with graphlib's TopologicalSorter similar to the way it is used in migrations, this way every file will only need to be processed once and we can detect and handle circular imports without having to throw an error.
Change History (3)
comment:1 by , 4 weeks ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 4 weeks ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:3 by , 4 weeks ago
| Has patch: | set |
|---|
Thanks for the migrations example. We also use it in
Media.