Skip to content

Commit

Permalink
chore: investigate delivery report (#17684)
Browse files Browse the repository at this point in the history
* chore: investigate delivery report

* async always leaks... try event
  • Loading branch information
pauldambra authored Sep 29, 2023
1 parent 44dde01 commit 1162f7d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions posthog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import secrets
import string
import subprocess
import threading
import time
import uuid
import zlib
Expand Down Expand Up @@ -1192,10 +1193,22 @@ def wait_for_parallel_celery_group(task: Any, max_timeout: Optional[datetime.tim

start_time = timezone.now()

while not task.ready():
if timezone.now() - start_time > max_timeout:
raise TimeoutError("Timed out waiting for celery task to finish")
time.sleep(0.1)
event = threading.Event()

while not event.is_set():
if task.ready():
event.set()
else:
if timezone.now() - start_time > max_timeout:
logger.error(
"Timed out waiting for celery task to finish",
methods=dir(task),
task=task,
timeout=max_timeout,
start_time=start_time,
)
raise TimeoutError("Timed out waiting for celery task to finish")
event.wait(0.1)
return task


Expand Down

0 comments on commit 1162f7d

Please sign in to comment.