Skip to content

Commit

Permalink
fix(batch-exports-backfill): Ensure at least one heartbeat is sent
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfarias committed Oct 19, 2023
1 parent 847032a commit 0a16034
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions posthog/temporal/workflows/backfill_batch_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class HeartbeatDetails(typing.NamedTuple):
wait_start_at: str

def make_activity_heartbeat_while_running(
self, function_to_run: collections.abc.Callable, heartbeat_timeout: dt.timedelta, factor: int = 2
self, function_to_run: collections.abc.Callable, heartbeat_timeout: dt.timedelta, factor: int = 120
) -> collections.abc.Callable[..., collections.abc.Coroutine]:
"""Return a callable that returns a coroutine that hearbeats with these HeartbeatDetails.
Expand All @@ -53,7 +53,7 @@ async def heartbeat_while_running(*args, **kwargs):
heartbeat_task = asyncio.create_task(heartbeat())

try:
await function_to_run(*args, **kwargs)
return await function_to_run(*args, **kwargs)
finally:
heartbeat_task.cancel()
await asyncio.wait([heartbeat_task])
Expand Down Expand Up @@ -210,11 +210,6 @@ async def wait_for_schedule_backfill_in_range(
f'AND StartTime >= "{now.isoformat()}"'
)

workflows = [workflow async for workflow in client.list_workflows(query=query)]

if workflows and check_workflow_executions_not_running(workflows) is True:
return

done = False
while not done:
await asyncio.sleep(wait_delay)
Expand Down

0 comments on commit 0a16034

Please sign in to comment.