From cd44e47a412f28fc35586cce6cc3f5b98dc81116 Mon Sep 17 00:00:00 2001 From: Marco0300 Date: Sat, 5 Sep 2026 17:56:10 +0200 Subject: [PATCH] deploy Maps v12 update --- .env.example | 2 +- README.md | 2 +- api/server.py | 15 ++++++++++++++- docker-compose.yml | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 4b8e207..5ca5cf1 100644 --- a/.env.example +++ b/.env.example @@ -9,7 +9,7 @@ GMAPS_API_MODE=standard GMAPS_API_KEY= # A single personal run may take several minutes. -GMAPS_REQUEST_TIMEOUT=300 +GMAPS_REQUEST_TIMEOUT=900 GMAPS_POLL_SECONDS=2 # Optional OpenAI-compatible provider for AI analysis and tailored drafts. diff --git a/README.md b/README.md index 884ce42..d5eb17d 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ error rather than remaining stuck forever. | `GMAPS_HOST_PORT` | `8081` | Host port for the Maps worker admin UI | | `GMAPS_API_MODE` | `standard` | `standard` for the bundled worker; `saas` only for the optional SaaS API | | `GMAPS_API_KEY` | empty | Not required in standard mode; only used in SaaS mode | -| `GMAPS_REQUEST_TIMEOUT` | `300` | Per-job scraper timeout in seconds | +| `GMAPS_REQUEST_TIMEOUT` | `900` | Maximum wait for the Maps worker in seconds; raise it for very large searches | | `GMAPS_POLL_SECONDS` | `2` | Poll interval while a job is running | | `DISCOVERY_BACKEND` | `gmaps` when `GMAPS_URL` is set | Set to `browser` only for the bounded public-search fallback | | `AI_BASE_URL` | empty | Optional OpenAI-compatible `/chat/completions` endpoint | diff --git a/api/server.py b/api/server.py index 961e04a..2bd201b 100644 --- a/api/server.py +++ b/api/server.py @@ -33,7 +33,10 @@ except ImportError: # tests import the module as api.server DB_PATH = os.environ.get("PROSPECT_DB", "/data/prospects.db") MAX_RESULTS = 50 GMAPS_POLL_SECONDS = float(os.environ.get("GMAPS_POLL_SECONDS", "2")) -GMAPS_REQUEST_TIMEOUT = int(os.environ.get("GMAPS_REQUEST_TIMEOUT", "300")) +# Maps searches can legitimately take several minutes, especially when email +# extraction is enabled. Fifteen minutes is the safe default; it remains +# configurable for smaller or larger personal runs. +GMAPS_REQUEST_TIMEOUT = int(os.environ.get("GMAPS_REQUEST_TIMEOUT", "900")) GMAPS_URL = os.environ.get("GMAPS_URL", "").strip().rstrip("/") # The bundled gosom/google-maps-scraper image exposes a local, unauthenticated # REST API. The optional SaaS edition uses a different API and requires an @@ -561,6 +564,16 @@ def poll_gmaps_job(job_id: str, progress: Callable[[str, int, int], None] | None error = field_value(response, "error", "Error") raise RuntimeError("gmaps_job_" + status + (":" + as_text(error) if error else "")) time.sleep(max(0.5, GMAPS_POLL_SECONDS)) + # The worker can finish writing its CSV just after its status endpoint + # exceeds our polling window. Recover a completed/partial result when it + # is available rather than discarding the run as a false failure. + if GMAPS_API_MODE == "standard": + try: + recovered = download_standard_results(job_id) + if recovered: + return recovered + except Exception: + pass raise RuntimeError("gmaps_job_timeout") diff --git a/docker-compose.yml b/docker-compose.yml index 6ce48fd..b74095b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,7 +22,7 @@ services: GMAPS_URL: ${GMAPS_URL:-http://gmaps:8080} GMAPS_API_MODE: ${GMAPS_API_MODE:-standard} GMAPS_API_KEY: ${GMAPS_API_KEY:-} - GMAPS_REQUEST_TIMEOUT: ${GMAPS_REQUEST_TIMEOUT:-300} + GMAPS_REQUEST_TIMEOUT: ${GMAPS_REQUEST_TIMEOUT:-900} GMAPS_POLL_SECONDS: ${GMAPS_POLL_SECONDS:-2} AI_BASE_URL: ${AI_BASE_URL:-} AI_API_KEY: ${AI_API_KEY:-}