Skip to content

Commit 906e9d8

Browse files
committed
.
1 parent f2a9f38 commit 906e9d8

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

sentry_sdk/integrations/strawberry.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@ def _sentry_patched_schema_init(self, *args, **kwargs):
9999
if integration.async_execution is not None:
100100
should_use_async_extension = integration.async_execution
101101
else:
102-
# use the sync extension by default
103-
warnings.warn(
104-
"Assuming strawberry is running sync. If not, initialize the integration as StrawberryIntegration(async_execution=True).",
105-
stacklevel=2,
106-
)
102+
# try to figure it out ourselves
103+
should_use_async_extension = _guess_if_using_async(extensions)
104+
105+
if should_use_async_extension is None:
106+
warnings.warn(
107+
"Assuming strawberry is running sync. If not, initialize the integration as StrawberryIntegration(async_execution=True).",
108+
stacklevel=2,
109+
)
110+
should_use_async_extension = False
107111

108112
# remove the built in strawberry sentry extension, if present
109113
extensions = [
@@ -377,3 +381,13 @@ def inner(event, hint):
377381
return event
378382

379383
return inner
384+
385+
386+
def _guess_if_using_async(extensions):
387+
# type: (List[SchemaExtension]) -> Optional[bool]
388+
if StrawberrySentryAsyncExtension in extensions:
389+
return True
390+
elif StrawberrySentrySyncExtension in extensions:
391+
return False
392+
393+
return None

0 commit comments

Comments
 (0)