Shutdown and Draining
The default behavior of most SDKs is to send out events over the network asynchronously in the background. This means that some events might be lost if the application shuts down unexpectedly. The SDKs provide mechanisms to cope with this.
The Python SDK automatically drains on shutdown unless the
AtExitIntegration is removed or the
config key is set to 0. To manually drain the client provides a
from sentry_sdk import Hub client = Hub.current.client if client is not None: client.close(timeout=2.0)
After a call to
close, the client cannot be used anymore. It's important to
close immediately before shutting down the application.
flush method drains the event queue while keeping the
client enabled for continued use.