bugsnag / bugsnag-python

Official BugSnag error monitoring and error reporting for django, flask, tornado and other python apps.
https://docs.bugsnag.com/platforms/python/
MIT License
86 stars 42 forks source link

Add flush method that waits for in-flight requests #377

Closed imjoehaines closed 6 months ago

imjoehaines commented 6 months ago

Goal

This allows users to wait for any outstanding bugsnag requests to finish before exiting, e.g.:

client = Client()
client.notify(some_exception)
client.session_tracker.start_session()

# some time later

try:
    client.flush(timeout_ms=2000)  # timeout after 2 seconds
    # the event & session have both been delivered
except:
    pass  # timeout was exceeded

sys.exit()