Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

python-sdk: include "cancelled" in CrawlJob.status and exit wait loop on cancel (fixes #2190) (#2240)

Jeel Rupareliya57babbaf0998
diff --git a/.gitignore b/.gitignore
index 1955a8183..79d3a4db1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,4 +44,6 @@ gke-key.json
CLAUDE.local.md
-*.egg-info/
\ No newline at end of file
+*.egg-info/
+# local SDK venv
+apps/python-sdk/.venv/
diff --git a/apps/python-sdk/.gitignore b/apps/python-sdk/.gitignore
index 386c77b22..5cd7c8b60 100644
--- a/apps/python-sdk/.gitignore
+++ b/apps/python-sdk/.gitignore
@@ -1,4 +1,6 @@
bin
build
include
-lib
\ No newline at end of file
+lib
+# local venv
+apps/python-sdk/.venv/
diff --git a/apps/python-sdk/firecrawl/v2/methods/crawl.py b/apps/python-sdk/firecrawl/v2/methods/crawl.py
index abcce4902..64f0c6d3f 100644
--- a/apps/python-sdk/firecrawl/v2/methods/crawl.py
+++ b/apps/python-sdk/firecrawl/v2/methods/crawl.py
@@ -333,7 +333,7 @@ def wait_for_crawl_completion(
crawl_job = get_crawl_status(client, job_id)
# Check if job is complete
- if crawl_job.status in ["completed", "failed"]:
+ if crawl_job.status in ["completed", "failed", "cancelled"]:
return crawl_job
# Check timeout
diff --git a/apps/python-sdk/firecrawl/v2/types.py b/apps/python-sdk/firecrawl/v2/types.py
index 10a436869..5b37a6776 100644
--- a/apps/python-sdk/firecrawl/v2/types.py
+++ b/apps/python-sdk/firecrawl/v2/types.py
@@ -348,7 +348,7 @@ class CrawlResponse(BaseModel):
class CrawlJob(BaseModel):
"""Crawl job status and progress data."""
- status: Literal["scraping", "completed", "failed"]
+ status: Literal["scraping", "completed", "failed", "cancelled"]
total: int = 0
completed: int = 0
credits_used: int = 0