Skip to content

Commit 5540bd1

Browse files
committed
no shared state
1 parent e043f22 commit 5540bd1

File tree

1 file changed

+4
-16
lines changed
  • ddtrace/contrib/internal/dd_trace_api

1 file changed

+4
-16
lines changed

ddtrace/contrib/internal/dd_trace_api/patch.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,16 @@ def _proxy_span_arguments(args: List, kwargs: Dict) -> Tuple[List, Dict]:
3535

3636

3737
def _call_on_real_instance(
38-
operand_stub: dd_trace_api._Stub,
39-
method_name: str,
40-
retval_from_api: Optional[Any],
41-
state_shared_with_api: Dict,
42-
*args: List,
43-
**kwargs: Dict
38+
operand_stub: dd_trace_api._Stub, method_name: str, retval_from_api: Optional[Any], *args: List, **kwargs: Dict
4439
) -> None:
4540
"""
4641
Call `method_name` on the real object corresponding to `operand_stub` with `args` and `kwargs` as arguments.
47-
Pass the return value back to the API layer via the mutable `state_shared_with_api`.
4842
4943
Store the value that will be returned from the API call we're in the middle of, for the purpose
5044
of mapping from those Stub objects to their real counterparts.
5145
"""
5246
args, kwargs = _proxy_span_arguments(args, kwargs)
5347
retval_from_impl = getattr(_STUB_TO_REAL[operand_stub], method_name)(*args, **kwargs)
54-
if "impl_return_value" in state_shared_with_api:
55-
state_shared_with_api["impl_return_value"] = retval_from_impl
5648
if retval_from_api is not None:
5749
_STUB_TO_REAL[retval_from_api] = retval_from_impl
5850

@@ -62,14 +54,10 @@ def _hook(name, hook_args):
6254
if not dd_trace_api.__datadog_patch or not name.startswith(_DD_HOOK_PREFIX):
6355
return
6456
args = hook_args[0][0]
65-
state_shared_with_api = args[0]
57+
stub_self = args[0]
58+
api_return_value = args[1]
6659
_call_on_real_instance(
67-
state_shared_with_api.get("stub_self"),
68-
name.replace(_DD_HOOK_PREFIX, "").rsplit(".", 1)[-1],
69-
state_shared_with_api.get("api_return_value"),
70-
state_shared_with_api,
71-
*args[1:],
72-
**hook_args[0][1]
60+
stub_self, name.replace(_DD_HOOK_PREFIX, "").rsplit(".", 1)[-1], api_return_value, *args[2:], **hook_args[0][1]
7361
)
7462

7563

0 commit comments

Comments
 (0)