Skip to content

Conversation

@filintod
Copy link
Contributor

@filintod filintod commented Aug 20, 2025

Description

Make it possible to use python workflow that manages code using asyncio to retrofit code that is already written as async/await.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@filintod filintod changed the title initial asyncio implemenation after durable task asyncio work initial asyncio implementation after durable task asyncio work Aug 20, 2025
These examples mirror `examples/workflow/` but author orchestrators with `async def` using the
async workflow APIs. Activities remain regular functions unless noted.

How to run:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add a venv reference in here too

Comment on lines 1 to 11
# dapr-ext-workflow-dev>=1.15.0.dev
# dapr-dev>=1.15.0.dev

# local development: install local packages in editable mode

# if using dev version of durabletask-python
-e ../../../durabletask-python

# if using dev version of dapr-ext-workflow
-e ../../ext/dapr-ext-workflow
-e ../..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# dapr-ext-workflow-dev>=1.15.0.dev
# dapr-dev>=1.15.0.dev
# local development: install local packages in editable mode
# if using dev version of durabletask-python
-e ../../../durabletask-python
# if using dev version of dapr-ext-workflow
-e ../../ext/dapr-ext-workflow
-e ../..
dapr-ext-workflow-dev>=1.15.0.dev
dapr-dev>=1.15.0.dev
# local development: install local packages in editable mode
# if using dev version of durabletask-python
# -e ../../../durabletask-python
# if using dev version of dapr-ext-workflow
# -e ../../ext/dapr-ext-workflow
# -e ../..

Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
@filintod filintod marked this pull request as ready for review November 20, 2025 06:36
@filintod filintod requested review from a team as code owners November 20, 2025 06:36
Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
def hello_act(ctx: WorkflowActivityContext, wf_input):
global counter
counter += wf_input
return f'Activity returned {wf_input}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filintod It'd be very useful to be able to define async activities like so:

@wfr.async_activity(name='async_hello_act')
async def hello_act(ctx: WorkflowActivityContext, wf_input):
    result = await some_async_func(wf_input)
    return result

Would it make sense to include support for that in this PR?

print(f'Child workflow returned {result_4}')

# Event vs timeout using when_any
event_1 = ctx.wait_for_external_event(event_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't these become async as well?

@passuied
Copy link
Contributor

@filintod looking at the examples you've added I think you would benefit from either waiting for my PR to be merged or merging that PR into your branch.
Unfortunately mixing sync and async has been leading to deadlocks/blocked thread when we tried to use the sync WorkflowClient in async methods... We had to use run_in_threadpool() to avoid this issue...

Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants