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

Optionally run a coroutine when using dispatch.run_forever #180

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

chriso
Copy link
Contributor

@chriso chriso commented Jun 27, 2024

The behavior of dispatch.run changed recently. Previously it would start a Dispatch endpoint server and serve forever. It optionally accepted a function to run once the server had been started, allowing users to dispatch an initial function call. Now it requires a coroutine as input, and sets up the Dispatch endpoint server only for the lifetime of the coroutine. Once the coroutine returns, dispatch.run returns its result after tearing down the endpoint server.

Users may need the ability to debug what happened with their function calls after they returned. However, if the Dispatch endpoint exits, the CLI will exit too.

There's a dispatch.run_forever variant that's closer to the original behavior of dispatch.run. It serves the endpoint forever, however it doesn't accept a coroutine as input nor a function to run when the server has been started.

This PR updates dispatch.run_forever to accept the same input as dispatch.run. If a coroutine is provided, it's run when the server has been started. Unlike dispatch.run, it doesn't return the result of the coroutine, instead keeping the server (and CLI, if applicable) running.

@chriso chriso self-assigned this Jun 27, 2024
@chriso chriso merged commit 53adf19 into main Jun 27, 2024
7 checks passed
@chriso chriso deleted the run-forever-args branch June 27, 2024 03:33
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