Skip to content

Commit

Permalink
Centralize is_fn_sync
Browse files Browse the repository at this point in the history
  • Loading branch information
amh4r committed Mar 4, 2025
1 parent db74e6d commit 35f27c0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 0 additions & 2 deletions pkg/inngest/inngest/_internal/execution_lib/v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ async def run(
# # it). Sync functions are OK in async contexts, so it's OK if the
# # handler is sync.
if is_function_handler_async(handler):
step_lib.is_fn_sync.set(False)
output = await handler(
ctx=ctx,
step=step_lib.Step(
Expand All @@ -161,7 +160,6 @@ async def run(
),
)
elif is_function_handler_sync(handler):
step_lib.is_fn_sync.set(True)
output = handler(
ctx=ctx,
step=step_lib.StepSync(
Expand Down
4 changes: 4 additions & 0 deletions pkg/inngest/inngest/_internal/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ async def call(
steps: step_lib.StepMemos,
target_hashed_id: typing.Optional[str],
) -> execution_lib.CallResult:
step_lib.is_fn_sync.set(False)

middleware = middleware_lib.MiddlewareManager.from_manager(middleware)
for m in self._middleware:
middleware.add(m)
Expand Down Expand Up @@ -202,6 +204,8 @@ def call_sync(
steps: step_lib.StepMemos,
target_hashed_id: typing.Optional[str],
) -> execution_lib.CallResult:
step_lib.is_fn_sync.set(True)

middleware = middleware_lib.MiddlewareManager.from_manager(middleware)
for m in self._middleware:
middleware.add(m)
Expand Down
1 change: 0 additions & 1 deletion pkg/inngest/inngest/experimental/mocked/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def trigger(

memos = step_lib.StepMemos.from_raw(steps)

step_lib.is_fn_sync.set(fn.is_handler_async is False)
if fn.is_handler_async:
loop = async_lib.get_event_loop()
if loop is None:
Expand Down

0 comments on commit 35f27c0

Please sign in to comment.