chore: апи всегда возвращает ответ
This commit is contained in:
1 parent
dc441e60ef
commit
eefcf7a0a9
1 file changed
+11
-3
+11
-3
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import logging
|
||||
import traceback
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
from typing import Annotated
|
||||
@@ -157,9 +158,13 @@ async def solve(
|
||||
|
||||
async with AsyncStealthySession(**kwargs) as engine:
|
||||
result = await engine.fetch(payload.url, page_action=make_page_action(payload))
|
||||
finally:
|
||||
BROWSER_SLOTS += 1
|
||||
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
result_payload = {
|
||||
"error": str(e),
|
||||
"status": False
|
||||
}
|
||||
else:
|
||||
status = not "error" in result["actions"][-1]
|
||||
error = ["Something error", None][status]
|
||||
|
||||
@@ -173,5 +178,8 @@ async def solve(
|
||||
result_payload["html"] = result["html"]
|
||||
if error:
|
||||
result_payload["error"] = error
|
||||
finally:
|
||||
BROWSER_SLOTS += 1
|
||||
|
||||
logger.info("Outgoing payload:\n%s", json.dumps(result_payload, indent=2, sort_keys=True, ensure_ascii=True))
|
||||
return result_payload
|
||||
Reference in new issue
Block a user