Skip to content

Commit 6e2c4f6

Browse files
committed
ref(client): Fix type checking with fallback asynctransport
GH-4601
1 parent de47da2 commit 6e2c4f6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

sentry_sdk/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,9 @@ async def _flush_and_close(
959959
await self._close_components_async()
960960

961961
if self.transport is not None:
962-
if isinstance(self.transport, AsyncHttpTransport):
962+
if isinstance(self.transport, AsyncHttpTransport) and hasattr(
963+
self.transport, "loop"
964+
):
963965

964966
try:
965967
flush_task = self.transport.loop.create_task(
@@ -996,7 +998,9 @@ def flush( # type: ignore[override]
996998
if timeout is None:
997999
timeout = self.options["shutdown_timeout"]
9981000

999-
if isinstance(self.transport, AsyncHttpTransport):
1001+
if isinstance(self.transport, AsyncHttpTransport) and hasattr(
1002+
self.transport, "loop"
1003+
):
10001004
try:
10011005
return self.transport.loop.create_task(
10021006
self._flush_async(timeout, callback)

sentry_sdk/transport.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
HTTP2_ENABLED = False
3030

3131
try:
32+
import anyio # noqa: F401
33+
3234
ASYNC_TRANSPORT_ENABLED = httpcore is not None
3335
except ImportError:
3436
ASYNC_TRANSPORT_ENABLED = False

0 commit comments

Comments
 (0)