Commit ca19d63
authored
feat: Preserve metadata on wrapped coroutines (#5105)
Copy metadata when wrapping coroutines in the patched `asyncio` task
factory. Uses the `functools.update_wrapper()` function that is also
used internally by `functools.wraps()`. Unlike when wrapping functions,
less metadata is available on coroutines, so `_wrap_coroutine()` is
equivalent to `functools.wraps()` but copies fewer attributes.
As `functools.update_wrapper()` checks for the existence of properties
first, copying metadata will not result in an `AttributeError` if
metadata is not available. See
https://docs.python.org/3/library/functools.html#functools.update_wrapper.
The SDK no longer overwrites coroutine metadata included in destroyed
errors as reported in
#5072.1 parent cf165e3 commit ca19d63
File tree
2 files changed
+26
-2
lines changed- sentry_sdk/integrations
- tests/integrations/asyncio
2 files changed
+26
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
32 | 46 | | |
33 | 47 | | |
34 | 48 | | |
| |||
39 | 53 | | |
40 | 54 | | |
41 | 55 | | |
| 56 | + | |
42 | 57 | | |
43 | 58 | | |
44 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
| |||
0 commit comments