Repository navigation
Commit 3565537
authored
fix: enforce the sync monitor timeout (#234)
## Summary
`OperationClient.monitor_operation` never applied its `timeout`.
`connect()` blocks until the stream ends, so the wait could last
forever. `GraphClient.materialize` (default 600 s) and `change_tier`
(600 s, documented to raise `TimeoutError`) both pass a timeout
expecting it to work. This was a follow-up from #233.
## Changes
- **Timeout:** a timer closes the stream when `timeout` passes. The read
ends and the call raises `TimeoutError("Operation … timed out after
Ns")`, the same message as the async monitor. The timer is cancelled
once the call returns, so a run that finishes in time is unaffected.
- **Reconnect:** `SSEClient` no longer reopens the stream when `close()`
lands during a reconnect backoff.
- **Type:** `MonitorOptions.timeout` is now `Optional[float]`, in
seconds. This widens the type and removes nothing.
The other #233 follow-up, a `mode="stream"` operator call failing,
turned out not to be a defect. The server only treats `mode=sync`
specially (`routers/graphs/operator/execute.py`). `stream`, `async` and
`auto` all answer `202`, which #233 already follows.
## Compatibility
Rides a client **patch**. Behaviour change: `materialize()` and
`change_tier()` now stop waiting at their timeout (600 s by default)
instead of waiting forever. `change_tier` raises `TimeoutError`, as its
docstring says. `materialize` returns a failed `MaterializationResult`.
The server-side operation keeps running either way.
## Testing
- **New tests:**
- a silent stream is closed at a 0.1 s timeout and raises;
- a run that finishes before its timeout returns its result;
- a close during the reconnect backoff doesn't reconnect.
- **`just test-all`:** 650 passed, 17 skipped. ruff, format and
basedpyright are clean.
🤖 Generated with [Claude Code](https://claude.com/claude-code)3 files changed
Lines changed: 84 additions & 4 deletions
File tree
- robosystems_client/clients
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | | - | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
135 | | - | |
136 | | - | |
137 | 136 | | |
138 | 137 | | |
139 | 138 | | |
| |||
225 | 224 | | |
226 | 225 | | |
227 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
228 | 237 | | |
229 | 238 | | |
230 | 239 | | |
231 | 240 | | |
232 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
233 | 245 | | |
234 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
235 | 252 | | |
236 | 253 | | |
237 | 254 | | |
| |||
240 | 257 | | |
241 | 258 | | |
242 | 259 | | |
| 260 | + | |
| 261 | + | |
243 | 262 | | |
244 | 263 | | |
245 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
271 | 275 | | |
272 | 276 | | |
273 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | | - | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
238 | 241 | | |
239 | 242 | | |
240 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
241 | 298 | | |
242 | 299 | | |
243 | 300 | | |
| |||
0 commit comments