File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -53,19 +53,19 @@ class _LambdaDecorator(object):
5353 and extracts/injects trace context.
5454 """
5555
56- _instance = None
5756 _force_new = False
5857
5958 def __new__ (cls , func ):
6059 """
61- If the decorator is accidentally applied to multiple functions or
62- the same function multiple times, only the first one takes effect.
60+ If the decorator is accidentally applied to the same function multiple times,
61+ only the first one takes effect.
6362
6463 If _force_new, always return a real decorator, useful for unit tests.
6564 """
66- if cls ._force_new or cls ._instance is None :
67- cls ._instance = super (_LambdaDecorator , cls ).__new__ (cls )
68- return cls ._instance
65+ if cls ._force_new or not getattr (func , "_dd_wrapped" , False ):
66+ wrapped = super (_LambdaDecorator , cls ).__new__ (cls )
67+ wrapped ._dd_wrapped = True
68+ return wrapped
6969 else :
7070 return _NoopDecorator (func )
7171
Original file line number Diff line number Diff line change @@ -269,13 +269,11 @@ def lambda_handler(event, context):
269269 # the second @datadog_lambda_wrapper should actually be no-op.
270270 datadog_lambda_wrapper ._force_new = False
271271
272- @datadog_lambda_wrapper
273- def lambda_handler_wrapper (event , context ):
274- lambda_handler (event , context )
272+ lambda_handler_double_wrapped = datadog_lambda_wrapper (lambda_handler )
275273
276274 lambda_event = {}
277275
278- lambda_handler_wrapper (lambda_event , get_mock_context ())
276+ lambda_handler_double_wrapped (lambda_event , get_mock_context ())
279277
280278 self .mock_patch_all .assert_called_once ()
281279 self .mock_wrapper_lambda_stats .flush .assert_called_once ()
You can’t perform that action at this time.
0 commit comments