Skip to content
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

Use deterministic version of asyncio.wait #116

Merged
merged 2 commits into from
Sep 24, 2024
Merged

Use deterministic version of asyncio.wait #116

merged 2 commits into from
Sep 24, 2024

Conversation

dandavison
Copy link
Contributor

@@ -98,7 +98,7 @@ async def run_action(action: Action) -> None:
should_return_task = asyncio.create_task(
workflow.wait_condition(lambda: return_value is not None)
)
done, _ = await asyncio.wait(
done, _ = await workflow.wait(
[gather_fut, should_return_task], return_when=asyncio.FIRST_COMPLETED
) # type: ignore
for fut in done:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Annoyingly, mypy doesn't infer that done is awaitable here. Not sure why that's not causing lint errors in the SDK (e.g. tests).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

kitchen_sink.py:105: error: Incompatible types in "await" (actual type "object", expected type "Awaitable[Any]")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Investigated a bit. The problem is the heterogenous arguments (an asyncio.Future and an asyncio.Task). mypy cannot handle this, whether for asyncio.wait or for our version of wait, but the wrong inference it makes is slightly different between the two.

@dandavison dandavison merged commit 9963c57 into main Sep 24, 2024
9 checks passed
@dandavison dandavison deleted the asyncio-wait branch September 24, 2024 21:51
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.

2 participants