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.
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 ofdispatch.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 asdispatch.run
. If a coroutine is provided, it's run when the server has been started. Unlikedispatch.run
, it doesn't return the result of the coroutine, instead keeping the server (and CLI, if applicable) running.