Skip to content

Commit 373942e

Browse files
committed
feat(transport): Add kill method for async transport
Implement a kill method that properly shuts down the async transport. The httpcore async connection pool needs to be explicitly shutdown at the end of its usage. GH-4582
1 parent a51f5e4 commit 373942e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sentry_sdk/transport.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,16 @@ def _make_pool(
756756

757757
return httpcore.AsyncConnectionPool(**opts)
758758

759+
def kill(self: Self) -> None:
760+
761+
logger.debug("Killing HTTP transport")
762+
self._worker.kill()
763+
for task in self.background_tasks:
764+
task.cancel()
765+
self.background_tasks.clear()
766+
767+
self._loop.create_task(self._pool.aclose()) # type: ignore
768+
759769

760770
class HttpTransport(BaseHttpTransport):
761771
if TYPE_CHECKING:

0 commit comments

Comments
 (0)