Skip to content

Centralize default HTTP timeouts across session, compatibility, and upload flows#22

Merged
erseco merged 4 commits intomainfrom
copilot/implement-roadmap-task
Mar 16, 2026
Merged

Centralize default HTTP timeouts across session, compatibility, and upload flows#22
erseco merged 4 commits intomainfrom
copilot/implement-roadmap-task

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

This picks up a small roadmap reliability task by replacing scattered hardcoded HTTP timeouts with a shared configuration surface. The goal is to make timeout behavior consistent across session bootstrap, compatibility detection, scraping fallbacks, and upload paths.

  • Add shared timeout defaults

    • Introduce src/py_moodle/config.py with named timeout policies for:
      • routine requests
      • short-lived scrape/probe requests
      • standard uploads
      • large package uploads
  • Replace hardcoded values in core flows

    • session.py: use the shared request timeout for sesskey fallback fetches and webservice calls
    • compat.py: use the shared request timeout for version detection via webservice and dashboard probing
    • module.py: use the shared scrape timeout for label intro fallback scraping
    • upload.py: default webservice uploads to the shared upload timeout
    • draftfile.py: default draft uploads to the shared large-upload timeout and add explicit request timeouts to draft-item and repo-detection calls
    • scorm.py: reuse the shared large-upload timeout for SCORM package uploads
  • Add focused regression coverage

    • Add unit tests to verify the updated code paths consume the centralized timeout constants rather than embedding local values

Example of the new timeout contract:

from py_moodle.config import (
    DEFAULT_REQUEST_TIMEOUT,
    DEFAULT_SCRAPE_TIMEOUT,
    DEFAULT_UPLOAD_TIMEOUT,
    DEFAULT_LARGE_UPLOAD_TIMEOUT,
)

response = session.post(url, timeout=DEFAULT_REQUEST_TIMEOUT)
itemid = upload_file_webservice(base_url, token, file_path, DEFAULT_UPLOAD_TIMEOUT)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits March 16, 2026 12:59
Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
Copilot AI changed the title [WIP] Add roadmap task implementation Centralize default HTTP timeouts across session, compatibility, and upload flows Mar 16, 2026
Copilot AI requested a review from erseco March 16, 2026 13:04
@erseco erseco marked this pull request as ready for review March 16, 2026 13:15
@erseco erseco merged commit 140e788 into main Mar 16, 2026
13 checks passed
@erseco erseco deleted the copilot/implement-roadmap-task branch March 16, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants