File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
tests/integrations/asyncio Expand file tree Collapse file tree 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):
3232 # type: (Any, Any) -> Any
3333
3434 async def _coro_creating_hub_and_span ():
35- # type: () -> None
35+ # type: () -> Any
3636 hub = Hub (Hub .current )
37+ result = None
38+
3739 with hub :
3840 with hub .start_span (op = OP .FUNCTION , description = coro .__qualname__ ):
3941 try :
40- await coro
42+ result = await coro
4143 except Exception :
4244 reraise (* _capture_exception (hub ))
4345
46+ return result
47+
4448 # Trying to use user set task factory (if there is one)
4549 if orig_task_factory :
4650 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(
155155 assert error_event ["exception" ]["values" ][0 ]["value" ] == "division by zero"
156156 assert error_event ["exception" ]["values" ][0 ]["mechanism" ]["handled" ] is False
157157 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