Skip to content

Commit cd8a35f

Browse files
committed
ref(client): Fix redundant async flush helper flushes
GH-4601
1 parent 4a7b8ce commit cd8a35f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sentry_sdk/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ async def _flush_and_close(
951951
_flush_and_close(timeout, callback)
952952
)
953953
except RuntimeError:
954+
self._close_components()
954955
logger.warning("Event loop not running, aborting close.")
955956
return None
956957
# Enforce flush before shutdown
@@ -975,12 +976,6 @@ def flush( # type: ignore[override]
975976
if self.transport is not None:
976977
if timeout is None:
977978
timeout = self.options["shutdown_timeout"]
978-
assert timeout is not None # shutdown_timeout should never be None
979-
980-
self.session_flusher.flush()
981-
982-
if self.log_batcher is not None:
983-
self.log_batcher.flush()
984979

985980
if isinstance(self.transport, AsyncHttpTransport):
986981
try:
@@ -991,6 +986,11 @@ def flush( # type: ignore[override]
991986
logger.warning("Event loop not running, aborting flush.")
992987
return None
993988
else:
989+
self.session_flusher.flush()
990+
991+
if self.log_batcher is not None:
992+
self.log_batcher.flush()
993+
994994
self.transport.flush(timeout=timeout, callback=callback)
995995
return None
996996

0 commit comments

Comments
 (0)