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 json
|
||||||
import logging
|
import logging
|
||||||
|
import traceback
|
||||||
import uuid
|
import uuid
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
@@ -157,9 +158,13 @@ async def solve(
|
|||||||
|
|
||||||
async with AsyncStealthySession(**kwargs) as engine:
|
async with AsyncStealthySession(**kwargs) as engine:
|
||||||
result = await engine.fetch(payload.url, page_action=make_page_action(payload))
|
result = await engine.fetch(payload.url, page_action=make_page_action(payload))
|
||||||
finally:
|
except Exception as e:
|
||||||
BROWSER_SLOTS += 1
|
traceback.print_exc()
|
||||||
|
result_payload = {
|
||||||
|
"error": str(e),
|
||||||
|
"status": False
|
||||||
|
}
|
||||||
|
else:
|
||||||
status = not "error" in result["actions"][-1]
|
status = not "error" in result["actions"][-1]
|
||||||
error = ["Something error", None][status]
|
error = ["Something error", None][status]
|
||||||
|
|
||||||
@@ -173,5 +178,8 @@ async def solve(
|
|||||||
result_payload["html"] = result["html"]
|
result_payload["html"] = result["html"]
|
||||||
if error:
|
if error:
|
||||||
result_payload["error"] = 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))
|
logger.info("Outgoing payload:\n%s", json.dumps(result_payload, indent=2, sort_keys=True, ensure_ascii=True))
|
||||||
return result_payload
|
return result_payload
|
||||||
Reference in new issue
Block a user