Skip to content

Commit b90daf4

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 c935e9e commit b90daf4

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
@@ -761,6 +761,16 @@ def _make_pool(
761761

762762
return httpcore.AsyncConnectionPool(**opts)
763763

764+
def kill(self: Self) -> None:
765+
766+
logger.debug("Killing HTTP transport")
767+
self._worker.kill()
768+
for task in self.background_tasks:
769+
task.cancel()
770+
self.background_tasks.clear()
771+
772+
self._loop.create_task(self._pool.aclose()) # type: ignore
773+
764774

765775
class HttpTransport(BaseHttpTransport):
766776
if TYPE_CHECKING:

0 commit comments

Comments
 (0)