Skip to content

Chore: Use sessions with ssl settings for all requests - #245

Draft
iLLiCiTiT wants to merge 12 commits into
developfrom
enhancement/retries-enhancement
Draft

iLLiCiTiT wants to merge 12 commits into
developfrom
enhancement/retries-enhancement

Conversation

@iLLiCiTiT

@iLLiCiTiT iLLiCiTiT commented Apr 14, 2025 •

Copy link
Copy Markdown
Member

Changelog Description

Requests made without a connection session now respect ssl_verify (including AYON_CA_FILE) and cert. SSL and proxy errors are no longer retried.

Additional review information

Requests without a session used requests.get, requests.post etc., which ignored the ssl settings of the connection. All REST requests, downloads and uploads now go through a requests.Session created by _create_requests_session. When the connection has no session, a temporary one is used and closed after the request. _base_functions_mapping and _session_functions_mapping were removed and requests use session.request(...) instead.

SSLError and ProxyError are subclasses of ConnectionError, so they were retried max_retries times and the response detail only said "Connection error". They're no longer retried, and the error message is kept in the response detail. Downloads and uploads re-raise them right away.

Also fixes upload header merging without a session, which compared header keys case-sensitively.

The original idea of this PR (raise exceptions instead of returning a fake response, and let HTTPAdapter handle retries) was dropped. Raising would break callers that check response.status, and adapter retries would stack on top of the existing retry loop, which now also handles 502/503 responses.

Testing notes:

  1. REST requests, downloads and uploads work with and without a session (ServerAPI(..., create_session=False)).
  2. Requests to an https url of an http server return an SSLError detail after a single attempt.
  3. Tests in tests/test_request_retries.py and tests/test_download_resume.py pass.

@antirotor

Copy link
Copy Markdown
Member

Btw this is interesting tool that can help https://pypi.org/project/retry/ - maybe make it easier to define behaviour with different arguments...

iLLiCiTiT and others added 2 commits November 10, 2026 12:20
…s-enhancement-claude

# Conflicts:
#	automated_api.py
#	ayon_api/server_api.py
Requests without a connection session used 'requests.get' etc., which
ignored 'ssl_verify' (including 'AYON_CA_FILE') and 'cert'. All
requests now go through 'requests.Session' created by
'_create_requests_session', and a temporary one is used when the
connection has no session.

SSL and proxy errors are no longer retried, as sending the request
again won't help. Their message is kept in the response detail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iLLiCiTiT iLLiCiTiT changed the title Chore: Requests handling enhancements Chore: Use sessions with ssl settings for all requests Nov 10, 2026

This branch has not been deployed

No deployments
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