Make per-call and contextual timeout handling consistent across all long-running APIs #990
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
timeoutparameter to methods that previously lacked one and fixing the timeout implementation to properly handle bothtotalandsocket_readtimeouts.The following operations now accept a
timeoutparameter with infinite timeout defaults:DockerContainer.log()- for streaming container logsDockerContainer.attach()- for attaching to container streamsDockerContainer.stats()- for streaming container statisticsDockerImages.build()- for building images (Add timeout support with improved documentation #983)DockerImages.export_image()- for exporting images as tarballsDockerImages.import_image()- for importing image tarballsDockerImages.push()- for pushing image to registry (Add timeout support with improved documentation #983)DockerImages.pull()- for pull image from registry (Add timeout support with improved documentation #983)DockerLogs.run()- for log streaming (Add timeout support with improved documentation #983)DockerContainer.commit()(Add missing consistent client timeout in DockerContainer.commit() #992)Additionally, the timeout handling in
Docker._query()has been fixed to set bothtotalandsock_readconsistently 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 overridestotalandsock_readtimeout values while preserving other timeouts such as connection establishment fromself.docker._timeout.Are there changes in behavior for the user?
New functionality:
total=Noneandsock_read=None), which matches the expected behavior for potentially long-running Docker operations.Behavior change:
Deprecation notice:
asyncio.timeout()block or passingaiohttp.ClientTimeoutobjects instead of float values.Related issue number
N/A
Checklist
changesfolder