Commit 7b750ceb authored by Barkin Simsek's avatar Barkin Simsek 🐢
Browse files

Record complete stack-trace for failed jobs

parent 96a42f86
import sys
import time import time
import logging import logging
import traceback
from typing import Union, Optional from typing import Union, Optional
from sqlalchemy import text from sqlalchemy import text
...@@ -140,14 +142,18 @@ class Worker: ...@@ -140,14 +142,18 @@ class Worker:
self.__fetcher.fetch() self.__fetcher.fetch()
# pylint: disable=W0703 # pylint: disable=W0703
except Exception as exception: except Exception:
# Get traceback information
T, V, TB = sys.exc_info()
error = "".join(traceback.format_exception(T, V, TB))
# If failed, put into the failed table # If failed, put into the failed table
failed = FetchFailed( failed = FetchFailed(
url=job.url, url=job.url,
options=job.options, options=job.options,
tbb_security_level=job.tbb_security_level, tbb_security_level=job.tbb_security_level,
captcha_monitor_version=self.__config["version"], captcha_monitor_version=self.__config["version"],
fail_reason=str(exception), fail_reason=str(error),
fetcher_id=job.fetcher_id, fetcher_id=job.fetcher_id,
domain_id=job.domain_id, domain_id=job.domain_id,
relay_id=job.relay_id, relay_id=job.relay_id,
...@@ -158,7 +164,7 @@ class Worker: ...@@ -158,7 +164,7 @@ class Worker:
self.__worker_id, self.__worker_id,
job.url, job.url,
job.fetcher_id, job.fetcher_id,
str(exception), str(error),
) )
else: else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment