fix: shutdown posthog after job (#31819)

* fix: change log level

A duplicate existing job is often a cause of concern.

* fix: avoid waiting indefinitely in long-living processes
This commit is contained in:
Ankush Menat 2025-03-20 11:19:20 +05:30 committed by GitHub
parent c5f79016eb
commit 5eabc7ebac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -115,7 +115,7 @@ def enqueue(
frappe.throw(_("`job_id` paramater is required for deduplication."))
job = get_job(job_id)
if job and job.get_status(refresh=False) in (JobStatus.QUEUED, JobStatus.STARTED):
frappe.logger().debug(f"Not queueing job {job.id} because it is in queue already")
frappe.logger().error(f"Not queueing job {job.id} because it is in queue already")
return
elif job:
# delete job to avoid argument issues related to job args
@ -725,7 +725,7 @@ def flush_telemetry():
to push events."""
ph = getattr(frappe.local, "posthog", None)
with suppress(Exception):
ph and ph.flush()
ph and ph.shutdown()
def _check_queue_size(q: Queue):

View file

@ -51,7 +51,7 @@ def init_telemetry():
return
with suppress(Exception):
frappe.local.posthog = Posthog(posthog_project_id, host=posthog_host)
frappe.local.posthog = Posthog(posthog_project_id, host=posthog_host, timeout=5, max_retries=3)
def capture(event, app, **kwargs):