fix: window_timeout for one-shot tasks, drop debug stderr logging
_poll_task now accepts window_timeout. For DirSize and MD5 (one-shot result windows), if only 599 errors arrive for window_timeout seconds without ever seeing the task alive (finished=False), return a fast "result window missed — please retry" error instead of waiting the full 60 s. Tasks that return finished=False at least once (large dirs, large files) are unaffected. Also removes the stale [dsm] debug stderr.write left in client.request(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1635,8 +1635,13 @@ async def test_dir_size_retries_on_transient_599(config: AppConfig) -> None:
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dir_size_times_out_on_persistent_599(config: AppConfig) -> None:
|
||||
"""dir_size returns Error: after 60 s timeout when DSM keeps returning 599."""
|
||||
async def test_dir_size_window_timeout_on_persistent_599(config: AppConfig) -> None:
|
||||
"""dir_size fails fast (window_timeout=3 s) when DSM returns only 599s.
|
||||
|
||||
Once the window_timeout elapses without ever seeing the task running
|
||||
(finished=False), _poll_task returns the "result window missed" error
|
||||
rather than waiting the full 60 s.
|
||||
"""
|
||||
client = MagicMock()
|
||||
|
||||
async def _request(api, method, version=None, params=None, **kwargs):
|
||||
@@ -1651,7 +1656,7 @@ async def test_dir_size_times_out_on_persistent_599(config: AppConfig) -> None:
|
||||
result = await tools["dir_size"](path="/dead")
|
||||
|
||||
assert result.startswith("Error:")
|
||||
assert "timed out" in result.lower() or "60 seconds" in result
|
||||
assert "retry" in result.lower() or "window" in result.lower() or "poll" in result.lower()
|
||||
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user