Skip to content

Commit

Permalink
fix: Store before_shutdown hook in def
Browse files Browse the repository at this point in the history
  • Loading branch information
bahlo committed Sep 30, 2024
1 parent eb325df commit 7221766
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/axiom_py/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ def __init__(self, client: Client, dataset: str, level=NOTSET, interval=1):
self.timer = Timer(self.interval, self.flush)

# Make sure we flush before the client shuts down
client.before_shutdown(lambda: self.flush(), self.timer.cancel())
def before_shutdown():
self.flush()
self.timer.cancel()

client.before_shutdown(before_shutdown)

def emit(self, record):
"""Emit sends a log to Axiom."""
Expand Down

0 comments on commit 7221766

Please sign in to comment.