Skip to content

Commit 7b005e1

Browse files
committed
Emit warning when AsyncioIntegration is setup incorrectly
1 parent a97c53c commit 7b005e1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sentry_sdk/integrations/asyncio.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sentry_sdk
44
from sentry_sdk.consts import OP
55
from sentry_sdk.integrations import Integration, DidNotEnable
6-
from sentry_sdk.utils import event_from_exception, reraise
6+
from sentry_sdk.utils import event_from_exception, logger, reraise
77

88
try:
99
import asyncio
@@ -74,9 +74,15 @@ async def _coro_creating_hub_and_span():
7474
return task
7575

7676
loop.set_task_factory(_sentry_task_factory) # type: ignore
77+
7778
except RuntimeError:
7879
# When there is no running loop, we have nothing to patch.
79-
pass
80+
logger.warning(
81+
"There is no running asyncio loop so there is nothing Sentry can patch. "
82+
"Please make sure you call sentry_sdk.init() within a running "
83+
"asyncio loop for the AsyncioIntegration to work. "
84+
"See https://docs.sentry.io/platforms/python/integrations/asyncio/"
85+
)
8086

8187

8288
def _capture_exception():

0 commit comments

Comments
 (0)