#35669: Improve `RuntimeError: Max post-process passes exceeded.` error -------------------------------------+------------------------------------- Reporter: Michael | Owner: (none) Type: New feature | Status: new Component: contrib.staticfiles | Version: 5.1 Severity: Normal | Resolution: Keywords: collect static | Triage Stage: errors | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 1 | UI/UX: 0 -------------------------------------+------------------------------------- Description changed by Michael:
Old description: > Having just spend 3 hours trying to debug a collect static issue, to help > future travellers, I recommend printing the files that caused max depth > to be exceeded, often when a file references itself it causes recursion, > but the only clue it currently prints is 'All' which does not narrow down > the problem. We can surely do better than that! The proposed change > prints the problem files only that keep chaning and can't be resolved: > > I recommend changing from: > {{{ > # contrib/staticfiles/storage.py line 313: in def post_process(self, > paths, dry_run=False, **options): > unresolved_paths = [] > for i in range(self.max_post_process_passes): > substitutions = False > for name, hashed_name, processed, subst in > self._post_process( > paths, adjustable_paths, hashed_files > ): > # Overwrite since hashed_name may be newer. > processed_adjustable_paths[name] = (name, hashed_name, > processed) > if subst and i == self.max_post_process_passes - 1: > unresolved_paths.append(name) > substitutions = substitutions or subst > > if not substitutions: > break > > if substitutions: > problem_paths_str = ", ".join(unresolved_paths) if > unresolved_paths else "All" > yield problem_paths_str, None, RuntimeError("Max post-process > passes exceeded.") > }}} > > I recommend changing to: > {{{ > # contrib/staticfiles/storage.py line 313: in def post_process(self, > paths, dry_run=False, **options): > unresolved_paths = [] > # < -- add this line 1/5 > for i in range(self.max_post_process_passes): > substitutions = False > for name, hashed_name, processed, subst in > self._post_process( > paths, adjustable_paths, hashed_files > ): > # Overwrite since hashed_name may be newer. > processed_adjustable_paths[name] = (name, hashed_name, > processed) > if subst and i == self.max_post_process_passes - 1: > # < -- add this line 2/5 > unresolved_paths.append(name) > # < -- add this line 3/5 > substitutions = substitutions or subst > > if not substitutions: > break > > if substitutions: > problem_paths_str = ", ".join(unresolved_paths) if > unresolved_paths else "All" # < -- add this line 4/5 > yield problem_paths_str, None, RuntimeError("Max post-process > passes exceeded.") # < -- change this line 5/5 > }}} New description: Having just spend 3 hours trying to debug a collect static issue, to help future travellers, I recommend printing the files that caused max depth to be exceeded, often when a file references itself it causes recursion, but the only clue it currently prints is 'All' which does not narrow down the problem. We can surely do better than that! The proposed change prints the problem files only that keep chaning and can't be resolved: I recommend changing from: {{{ # contrib/staticfiles/storage.py line 313: in def post_process(self, paths, dry_run=False, **options): unresolved_paths = [] for i in range(self.max_post_process_passes): substitutions = False for name, hashed_name, processed, subst in self._post_process( paths, adjustable_paths, hashed_files ): # Overwrite since hashed_name may be newer. processed_adjustable_paths[name] = (name, hashed_name, processed) if subst and i == self.max_post_process_passes - 1: unresolved_paths.append(name) substitutions = substitutions or subst if not substitutions: break if substitutions: problem_paths_str = ", ".join(unresolved_paths) if unresolved_paths else "All" yield problem_paths_str, None, RuntimeError("Max post-process passes exceeded.") }}} I recommend changing to (see the comments on the right of the proposed changed lines 1/5 to 5/5): {{{ # contrib/staticfiles/storage.py line 313: in def post_process(self, paths, dry_run=False, **options): unresolved_paths = [] # < -- add this line 1/5 for i in range(self.max_post_process_passes): substitutions = False for name, hashed_name, processed, subst in self._post_process( paths, adjustable_paths, hashed_files ): # Overwrite since hashed_name may be newer. processed_adjustable_paths[name] = (name, hashed_name, processed) if subst and i == self.max_post_process_passes - 1: # < -- add this line 2/5 unresolved_paths.append(name) # < -- add this line 3/5 substitutions = substitutions or subst if not substitutions: break if substitutions: problem_paths_str = ", ".join(unresolved_paths) if unresolved_paths else "All" # < -- add this line 4/5 yield problem_paths_str, None, RuntimeError("Max post-process passes exceeded.") # < -- change this line 5/5 }}} -- -- Ticket URL: <https://code.djangoproject.com/ticket/35669#comment:2> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/010701913b0e2b62-916d0219-f5f0-459f-9cb0-1f0fea5a397c-000000%40eu-central-1.amazonses.com.