feat: Introduce tiered timeout system with per-endpoint configuration#653
feat: Introduce tiered timeout system with per-endpoint configuration#653
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #653 +/- ##
==========================================
+ Coverage 96.57% 96.67% +0.10%
==========================================
Files 45 45
Lines 4318 4336 +18
==========================================
+ Hits 4170 4192 +22
+ Misses 148 144 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9653d95 to
634577c
Compare
- Add `Timeout` type alias (`timedelta | Literal['no_timeout'] | None`) to `_consts.py` and export it from the public API - Accept `None` on abstract `HttpClient.call()` / `HttpClientAsync.call()` so the HTTP client resolves its own default timeout internally - Move `_calculate_timeout` into the impit HTTP client implementation since exponential timeout growth on retries is client-specific logic - Add `timeout` parameter to all public resource client methods for user-controllable per-request HTTP timeouts - Add timeout parameter to base methods `_list()`, `_create()`, and `_get_or_create()` which previously lacked it - Rename domain-specific Actor/Task run timeout from `timeout` to `run_timeout` to avoid ambiguity with the HTTP request timeout - Update docstrings to document three-state timeout semantics Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduce `timeout_max` parameter to cap exponential timeout growth independently from the initial timeout. Lower defaults to `DEFAULT_REQUEST_TIMEOUT=10s`, `DEFAULT_REQUEST_TIMEOUT_MAX=600s`, and `DEFAULT_MAX_RETRIES=4`, producing the sequence [10, 20, 40, 80, 160]. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
634577c to
ac20367
Compare
Pijukatel
left a comment
There was a problem hiding this comment.
I would be very careful about changing the actual timeouts. Can we please split this into 2 PRs:
- Refactoring (majority)
- Assigning different timeouts to API operations
|
|
||
| @property | ||
| def timeout_short(self) -> timedelta: | ||
| """Timeout for fast CRUD operations (e.g., get, update, delete).""" |
There was a problem hiding this comment.
I am not sure we can do such a blanket description. Some endpoints will have get/update/post even with the long timeout. For example, dealing with kvs value that can be very large? Might be other endpoints as well
Also, the timeout_short and timeout (medium) should probably be used only in idempotent requests, to avoid doing some non-idempotent operation twice just because of a short timeout.
| """Compute timeout for a request attempt with exponential increase, bounded by timeout_max. | ||
|
|
||
| For `'no_timeout'`, returns 0 (impit interprets this as no timeout). For `None`, uses the client-level timeout. | ||
| For `None` (resolved from `'no_timeout'`), returns `None` — impit uses client-level default. |
There was a problem hiding this comment.
This gets me confused about timeouts. Sometimes None means no timeout, sometimes default.
| ) | ||
|
|
||
| async def get(self, *, timeout: Timeout = None) -> Build | None: | ||
| async def get(self, *, timeout: Timeout = 'short') -> Build | None: |
There was a problem hiding this comment.
Just an example operation that changed from long (default) to short (see my comment about 2 PRs)
5071549 to
3d9f230
Compare
3d9f230 to
0ad2c46
Compare
Summary
short(5s by default),medium(30s by default),long(300s by default),max(600s cap by default).Timeouttype alias:timedelta | Literal['no_timeout', 'short', 'medium', 'long']timeout_max).shortfor CRUD,mediumfor list/create,longfor heavy ops)._internal_models.pyto_types.pyand consolidate type aliases (Timeout,JsonSerializable) into it.FAST_OPERATION_TIMEOUT,STANDARD_OPERATION_TIMEOUT).Timeout tiers
shortget,update,delete)mediumpush_items,get_items,set_record,add_request, batch operations), actorstart/call/abort, runresurrect/reboot/metamorphlongget_items/push_items/iterate_items, KVSget_record/set_record/get_record_as_bytes/stream_record, request queuebatch_add_requests/batch_delete_requests, logget/get_as_bytes/stream, actorbuild, runget_dataset_itemsno_timeoutmaxLet's discuss the best defaults.
What this solves
Test plan