Skip to content

Commit

Permalink
temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
amadolid committed Jul 4, 2024
1 parent 5f6f2b8 commit 1f5f411
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion jaseci_ai_kit/jac_misc/jac_misc/scraper/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ async def scrape(sr: ScraperRequest):
)
)
return {"task": task.get_name()}
return await async_scrape(sr.pages, sr.pre_configs, sr.detailed, sr.target)
return await async_scrape(
sr.pages, sr.pre_configs, sr.detailed, sr.target, sr.trigger_id
)

@app.post("/scrape_preview/")
async def scrape_preview(spr: ScraperPreviewRequest):
Expand Down
9 changes: 9 additions & 0 deletions jaseci_ai_kit/jac_misc/jac_misc/scraper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,24 @@ class Stopped(Exception):
@staticmethod
def add(trigger_id: str):
Process.queue.add(trigger_id)
print(Process.queue)

@staticmethod
def can_continue(trigger_id: str):
print("########### can_continue")
print(Process.queue)
print(trigger_id)
print(trigger_id in Process.queue)
if can := (trigger_id in Process.queue):
Process.queue.remove(trigger_id)
return not can

@staticmethod
def has_to_stop(trigger_id: str):
print("########### has_to_stop")
print(Process.queue)
print(trigger_id)
print(trigger_id in Process.queue)
if trigger_id in Process.queue:
Process.queue.remove(trigger_id)
raise Process.Stopped()
Expand Down

0 comments on commit 1f5f411

Please sign in to comment.