mirror of
https://github.com/langgenius/dify.git
synced 2026-06-16 22:11:09 +08:00
fix(watercrawl): bound result download timeout (#37495)
This commit is contained in:
parent
f9ed81c3f4
commit
fe64c5d4a8
@ -217,7 +217,7 @@ class WaterCrawlAPIClient(BaseAPIClient):
|
||||
return event_data["data"]
|
||||
|
||||
def download_result(self, result_object: dict[str, Any]):
|
||||
response = httpx.get(result_object["result"], timeout=None)
|
||||
response = httpx.get(result_object["result"], timeout=30)
|
||||
try:
|
||||
response.raise_for_status()
|
||||
result_object["result"] = response.json()
|
||||
|
||||
@ -242,11 +242,18 @@ class TestWaterCrawlAPIClient:
|
||||
client = WaterCrawlAPIClient(api_key="k")
|
||||
|
||||
response = _response(200, {"markdown": "body"})
|
||||
monkeypatch.setattr(client_module.httpx, "get", lambda *args, **kwargs: response)
|
||||
captured = {}
|
||||
|
||||
def fake_get(*args, **kwargs):
|
||||
captured.update(kwargs)
|
||||
return response
|
||||
|
||||
monkeypatch.setattr(client_module.httpx, "get", fake_get)
|
||||
|
||||
result = client.download_result({"result": "https://example.com/result.json"})
|
||||
|
||||
assert result["result"] == {"markdown": "body"}
|
||||
assert captured["timeout"] is not None
|
||||
response.close.assert_called_once()
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user