File tree 2 files changed +22
-2
lines changed
tests/integrations/asyncio
2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -32,15 +32,19 @@ def _sentry_task_factory(loop, coro):
32
32
# type: (Any, Any) -> Any
33
33
34
34
async def _coro_creating_hub_and_span ():
35
- # type: () -> None
35
+ # type: () -> Any
36
36
hub = Hub (Hub .current )
37
+ result = None
38
+
37
39
with hub :
38
40
with hub .start_span (op = OP .FUNCTION , description = coro .__qualname__ ):
39
41
try :
40
- await coro
42
+ result = await coro
41
43
except Exception :
42
44
reraise (* _capture_exception (hub ))
43
45
46
+ return result
47
+
44
48
# Trying to use user set task factory (if there is one)
45
49
if orig_task_factory :
46
50
return orig_task_factory (loop , _coro_creating_hub_and_span ()) # type: ignore
Original file line number Diff line number Diff line change @@ -155,3 +155,19 @@ async def test_exception(
155
155
assert error_event ["exception" ]["values" ][0 ]["value" ] == "division by zero"
156
156
assert error_event ["exception" ]["values" ][0 ]["mechanism" ]["handled" ] is False
157
157
assert error_event ["exception" ]["values" ][0 ]["mechanism" ]["type" ] == "asyncio"
158
+
159
+
160
+ @minimum_python_36
161
+ @pytest .mark .asyncio
162
+ async def test_task_result (sentry_init ):
163
+ sentry_init (
164
+ integrations = [
165
+ AsyncioIntegration (),
166
+ ],
167
+ )
168
+
169
+ async def add (a , b ):
170
+ return a + b
171
+
172
+ result = await asyncio .create_task (add (1 , 2 ))
173
+ assert result == 3 , result
You can’t perform that action at this time.
0 commit comments