Opened 84 minutes ago
Last modified 28 minutes 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: | no | 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 (2)
comment:1 by , 49 minutes ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 28 minutes ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
Thanks for the migrations example. We also use it in
Media.