Skip to content

Commit 23b8ea2

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 f01b00d commit 23b8ea2

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
@@ -766,8 +766,10 @@ def kill(self: Self) -> None:
766766
for task in self.background_tasks:
767767
task.cancel()
768768
self.background_tasks.clear()
769-
770-
self._loop.create_task(self._pool.aclose()) # type: ignore
769+
try:
770+
self._loop.create_task(self._pool.aclose()) # type: ignore
771+
except RuntimeError:
772+
logger.warning("Event loop not running, aborting kill.")
771773

772774

773775
class HttpTransport(BaseHttpTransport):

0 commit comments

Comments
 (0)