mirror of
https://github.com/jaypyles/Scraperr.git
synced 2025-12-14 19:55:56 +00:00
fix: issue with updating jobs
This commit is contained in:
@@ -17,7 +17,7 @@ async def process_job():
|
|||||||
if job:
|
if job:
|
||||||
LOG.info(f"Beginning processing job: {job}.")
|
LOG.info(f"Beginning processing job: {job}.")
|
||||||
try:
|
try:
|
||||||
_ = await update_job(job["id"], field="status", value="Scraping")
|
_ = await update_job([job["id"]], field="status", value="Scraping")
|
||||||
scraped = await scrape(
|
scraped = await scrape(
|
||||||
job["url"],
|
job["url"],
|
||||||
[Element(**j) for j in job["elements"]],
|
[Element(**j) for j in job["elements"]],
|
||||||
@@ -28,12 +28,12 @@ async def process_job():
|
|||||||
f"Scraped result for url: {job['url']}, with elements: {job['elements']}\n{scraped}"
|
f"Scraped result for url: {job['url']}, with elements: {job['elements']}\n{scraped}"
|
||||||
)
|
)
|
||||||
_ = await update_job(
|
_ = await update_job(
|
||||||
job["id"], field="result", value=jsonable_encoder(scraped)
|
[job["id"]], field="result", value=jsonable_encoder(scraped)
|
||||||
)
|
)
|
||||||
_ = await update_job(job["id"], field="status", value="Completed")
|
_ = await update_job(job["id"], field="status", value="Completed")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_ = await update_job(job["id"], field="status", value="Failed")
|
_ = await update_job([job["id"]], field="status", value="Failed")
|
||||||
_ = await update_job(job["id"], field="result", value=e)
|
_ = await update_job([job["id"]], field="result", value=e)
|
||||||
LOG.error(f"Exception as occured: {e}\n{traceback.print_exc()}")
|
LOG.error(f"Exception as occured: {e}\n{traceback.print_exc()}")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user