-
Notifications
You must be signed in to change notification settings - Fork 103
Add deterministic alternatives for asyncio.wait and asyncio.as_completed #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2bc0718
Add deterministic alternatives for asyncio.wait and asyncio.as_completed
cretz d1eb4bd
Minor 3.8-compat typing fix
cretz b363435
Merge branch 'main' into asyncio-non-det
cretz 0802ad5
Warn when invalid asyncio calls are used
cretz 462ad1b
Merge branch 'main' into asyncio-non-det
cretz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering about naming these
workflow.asyncio_wait()
andworkflow.asyncio_as_completed()
.The main reason is that
workflow.wait()
will be confused withworkflow.wait_condition()
. It may just be a hiccup that they'll get over, but it would be nice not to cause users that hiccup.Another reason is that
workflow.asyncio_xxx()
is just directly saying exactly what it is: a shim that is basically exactly the same as the utility fromasyncio
. It makes it clear that they are utilities for dealing with arbitrary tasks/coroutines rather than being a special sort ofas_completed
orwait
that has to do with waiting or completing Temporal-specific entities.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered it, but we don't have
asyncio_sleep
, justsleep
. I think these don't need to necessarily be seen as asyncio utilities, they can be seen as workflow utilities that just so happen to be in asyncio as well. I think they work well as workflow utilities just likewait_condition
. (same foruuid4()
andtime()
andrandom()
and other Python copies we don't prefix with their originating module name +_
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see the analogy there: we don't have
workflow.sleep()
, instead users just useasyncio.sleep()
. Here, users would callasyncio.xxx()
but they shouldn't, so we point them toworkflow.asyncio_xxx()
.workflow.wait_condition()
is an extremely important API and I really worry that introducingworkflow.wait()
will confuse users and damage DX. It's a very similar name toworkflow.Await()
/Workflow.await()
that users may have come across in the Go and Java SDKs, and IDEs will offer it first when users are exploring theworkflow
namespace. I'd like to wait for other team opinions on this.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, correct, I was thinking of other SDKs that do have sleep and don't prefix it. In Python we are able to reuse sleep. We do have
time()
,time_ns()
,random()
, anduuid4()
though that are copies of other Python module functions and we don't prefix those.Python has
wait
andwait_for
which are different things too and if they can expect users to understand the difference I think we can too.👍