kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

install_cexts.py fails the build on a brief piwheels outage: retries have no delay and hide their errors

Open rtibblesbot opened this issue 3 weeks ago • 1 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Observed behavior

make dist (and so make -C platforms/android stage-workspace-tar) dies in staticdeps-cext whenever piwheels' index page fails to load for a few seconds:

uv run --script build_tools/install_cexts.py --file "requirements/cext.txt"
Unable to find package cffi on https://www.piwheels.org/simple/.
make[1]: *** [Makefile:190: staticdeps-cext] Error 1
  • It happened twice in three hours on 2026-11-10/11, first for cryptography, then for cffi. Builds of the same tree between the two failures succeeded.
  • In the cffi run, cffi's PyPI page loaded, so the network was up. Only piwheels failed.

Cause

parse_pypi_and_piwheels in build_tools/install_cexts.py:

  • for _ in range(5): r = session.get(url): five attempts back to back, with no sleep. A blip of a second or two uses up all of them.
  • session.get has no timeout.
  • Each failure is logged with logger.info("Error retrieving %s: %s", url, e). No logging is configured, so the reason never prints and the build log shows only Unable to find package.

Expected behavior

  • A piwheels or PyPI outage of up to about a minute does not fail the build.
  • When retries are exhausted, the output names each attempt's error or status code.

Acceptance criteria

  • [ ] parse_pypi_and_piwheels waits between attempts with exponential backoff (e.g. 2s, 4s, 8s, 16s), totalling at least about 30s before giving up.
  • [ ] Each session.get passes a timeout.
  • [ ] Each failed attempt's exception or status is logged at WARNING, or included in the sys.exit message.
  • [ ] A unit test with a mocked session that fails twice and then returns 200 yields the package's tasks. With time.sleep patched, it asserts the backoff delays.
  • [ ] A unit test with a session that always fails exits with a message naming the last error.

Filed from learningequality/coding-agent#1431's diagnosis.

rtibblesbot avatar Nov 11 '26 09:11 rtibblesbot

Plan: parse_pypi_and_piwheels survives an index outage of about a minute and names the error when it gives up.

  • [ ] Back off, time out and report errors when fetching index pages
  • [ ] Self-review the produced code

Assumptions — the issue did not settle these; say so if one is wrong.

  • 6 attempts, so the sleeps are 2+4+8+16+32 = 62s. This covers the "about a minute" outage. If 5 attempts (30s) is wanted, drop one and the final sleep assertion.
  • 4xx responses are retried like 5xx, as they are today. If 404 should fail fast, a missing package exits at once instead of after ~62s.
  • except requests.RequestException replaces except Exception. If a non-requests error from session.get should be retried, widen the catch.

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Nov 11 '26 09:11 rtibblesbot