Skip to content

Commit 90346a5

Browse files
committed
Add silent failing to kill on event loop errors
Add a try/catch to ensure silent fail on kill in case the event loop shuts down. GH-4582
1 parent e1d7cdb commit 90346a5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sentry_sdk/transport.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,10 @@ def kill(self: Self) -> None:
768768
for task in self.background_tasks:
769769
task.cancel()
770770
self.background_tasks.clear()
771-
772-
self._loop.create_task(self._pool.aclose()) # type: ignore
771+
try:
772+
self._loop.create_task(self._pool.aclose()) # type: ignore
773+
except RuntimeError:
774+
logger.warning("Event loop not running, aborting kill.")
773775

774776

775777
class HttpTransport(BaseHttpTransport):

0 commit comments

Comments
 (0)