Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REST webapp improvement: Using `on_cleanup` is not the correct hook to use here, as this would run _after_ the event loop has closed, making it unsuitable for cancelling background tasks for example. `on_shutdown` is triggered before the REST app shuts down, thus it's able to clean up eg. Kafka clients, background tasks, etc. properly. Before this change, the symptom of the bug is most prevalent in the Karapace REST proxy and its "idle proxy janitor" background task. Stopping the application when the janitor task is not running is straightforward, however when any `UserRestProxy` is present (ie. some requests have already been handled) and the task is running, stopping the REST proxy hangs or needs multiple signals to shut down. With the new `AIOKafkaProducer` implementation (which runs a poll-thread in the background) this results in an application that is unable to gracefully shutdown, only SIGKILL works. Using the `on_shutdown` hook fixes this issue, as we still have an event loop available to be able to cancel background tasks, etc.
- Loading branch information