|
30 | 30 | from .multiplexed import multiplexed_result_list, multiplexed_result_stream |
31 | 31 | from .stream import Stream |
32 | 32 | from .types import JSONObject, MutableJSONObject, PortInfo |
33 | | -from .utils import identical, parse_result |
| 33 | +from .utils import _suppress_timeout_deprecation, identical, parse_result |
34 | 34 |
|
35 | 35 |
|
36 | 36 | if TYPE_CHECKING: |
@@ -286,14 +286,20 @@ async def kill(self, **kwargs) -> None: |
286 | 286 | ): |
287 | 287 | pass |
288 | 288 |
|
289 | | - async def wait(self, *, timeout=None, **kwargs) -> Dict[str, Any]: |
290 | | - data = await self.docker._query_json( |
291 | | - f"containers/{self._id}/wait", |
292 | | - method="POST", |
293 | | - params=kwargs, |
294 | | - timeout=timeout, |
295 | | - ) |
296 | | - return data |
| 289 | + async def wait(self, *, timeout: float | None = None, **kwargs) -> Dict[str, Any]: |
| 290 | + # The wait API is an exception from deprecation of the total timeout. |
| 291 | + # Use a context variable to suppress the warning in a thread-safe and async-safe manner. |
| 292 | + token = _suppress_timeout_deprecation.set(True) |
| 293 | + try: |
| 294 | + data = await self.docker._query_json( |
| 295 | + f"containers/{self._id}/wait", |
| 296 | + method="POST", |
| 297 | + params=kwargs, |
| 298 | + timeout=timeout, |
| 299 | + ) |
| 300 | + return data |
| 301 | + finally: |
| 302 | + _suppress_timeout_deprecation.reset(token) |
297 | 303 |
|
298 | 304 | async def delete(self, **kwargs) -> None: |
299 | 305 | async with self.docker._query( |
|
0 commit comments