Skip to content

Conversation

@achimnol
Copy link
Member

@achimnol achimnol commented Dec 19, 2025

What do these changes do?

As a follow-up to #983, this PR makes timeout handling consistent across all long-running Docker API operations by adding an explicit timeout parameter to methods that previously lacked one and fixing the timeout implementation to properly handle both total and socket_read timeouts.

The following operations now accept a timeout parameter with infinite timeout defaults:

Additionally, the timeout handling in Docker._query() has been fixed to set both total and sock_read consistently when a float timeout is provided, preventing timeout inconsistencies that could cause operations to fail prematurely.

Now all above methods consistently use the new base method _resolve_long_running_timeout() which selectively overrides total and sock_read timeout values while preserving other timeouts such as connection establishment from self.docker._timeout.

Are there changes in behavior for the user?

New functionality:

  • Users can now explicitly control timeouts for long-running operations like build, import, export, logs, attach, and stats.
  • These operations default to infinite timeout (both total=None and sock_read=None), which matches the expected behavior for potentially long-running Docker operations.

Behavior change:

  • When passing a float timeout value to any Docker API method, both the total timeout AND socket read timeout are now set to that value (previously only total was set). This ensures more consistent timeout behavior but may cause some operations to timeout differently than before.

Deprecation notice:

  • The deprecation warning message for float timeouts has been updated to encourage using asyncio.timeout() block or passing aiohttp.ClientTimeout objects instead of float values.

Related issue number

N/A

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • Add a new news fragment into the changes folder

@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

❌ Patch coverage is 73.07692% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.27%. Comparing base (d271832) to head (bd860a7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
aiodocker/docker.py 33.33% 5 Missing and 1 partial ⚠️
aiodocker/logs.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #990      +/-   ##
==========================================
+ Coverage   73.24%   73.27%   +0.03%     
==========================================
  Files          25       25              
  Lines        1798     1815      +17     
  Branches      241      244       +3     
==========================================
+ Hits         1317     1330      +13     
- Misses        401      405       +4     
  Partials       80       80              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@achimnol achimnol force-pushed the fix/consistent-timeout-for-long-running-apis branch from fa1a501 to 59f0fa9 Compare December 19, 2025 04:30
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