Skip to content

Commit

Permalink
fix: Type hints and early return
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfarias committed Jun 21, 2024
1 parent 6e968a9 commit eae9276
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion posthog/temporal/batch_exports/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def rewind_gen() -> collections.abc.Generator[T, None, None]:


@contextlib.asynccontextmanager
async def set_status_to_running_task(run_id: str | None, logger, timeout: float = 10.0) -> None:
async def set_status_to_running_task(
run_id: str | None, logger, timeout: float = 10.0
) -> typing.AsyncIterator[asyncio.Task]:
"""Manage a background task to set a batch export run to 'RUNNING' status.
This is intended to be used within a batch export's 'insert_*' activity. These activities cannot afford
Expand All @@ -53,6 +55,8 @@ async def set_status_to_running_task(run_id: str | None, logger, timeout: float
the status. This means that, worse case, the batch export status won't be displayed as 'RUNNING' while running.
"""
if run_id is None:
# Should never land here except in tests of individual activities
yield
return

background_task = asyncio.create_task(
Expand Down

0 comments on commit eae9276

Please sign in to comment.