deploy Maps v12 update

This commit is contained in:
Marco0300
2026-09-05 17:56:10 +02:00
parent e561227dde
commit cd44e47a41
4 changed files with 17 additions and 4 deletions
+14 -1
View File
@@ -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")