Skip to content

Commit b0390e6

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 7c5dec0 commit b0390e6

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

760760
return httpcore.AsyncConnectionPool(**opts)
761761

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

763773
class HttpTransport(BaseHttpTransport):
764774
if TYPE_CHECKING:

0 commit comments

Comments
 (0)