Refactor: linkcheck builder: reduce the lifetime of the 'response' variable#11432
Refactor: linkcheck builder: reduce the lifetime of the 'response' variable#11432AA-Turner merged 4 commits intosphinx-doc:masterfrom jayaddison:issue-11324-prep/linkcheck-refactor-response-variable-lifetime
Conversation
|
Thanks @jayaddison! A |
|
https://github.com/sphinx-doc/sphinx/actions/runs/5615478788/job/15215837543 -- LaTeX timed out
|
See also a similar test failure at: https://github.com/sphinx-doc/sphinx/actions/runs/5615865316/job/15217324918 |
| with retrieval_method(url=req_url, auth=auth_info, config=self.config, | ||
| **retrieval_kwargs, **kwargs) as response: | ||
| if response.ok and anchor and not contains_anchor(response, anchor): | ||
| raise Exception(__(f'Anchor {anchor!r} not found')) |
There was a problem hiding this comment.
It looks like I introduced a regression with the rewrite of these lines - and the regression is reported here: #11532 (comment)
Basically: when anchor checking is not enabled -- that is, self.linkcheck_anchors is False -- the first retrieval method returned is an HTTP HEAD request. It can have response.ok, and the anchor value may be non-empty -- because we continue to extract (partition) the anchor from the uri regardless of whether anchor linkchecking will be performed. The HTTP HEAD response doesn't contain a content body, so contains_anchor will return false, and the exception is raised.
I'll prepare a fixup/patch for this and some test coverage to cover this situation within the next few days.
Feature or Bugfix
Purpose
responsevariable that holds the results of HTTP request results should be considered live and is non-garbage-collectable.Detail
responsevariable may be a contributing factor to timeouts that occur during our unit tests.Relates