Closed
Description
When decorating multiple functions with Tracer.capture_method(), a RuntimeError is thrown if one of those methods contains a call to the other as it tries to run an event loop which is already running.
The offending code is here: https://github.com/awslabs/aws-lambda-powertools/blob/develop/python/aws_lambda_powertools/tracing/tracer.py#L454
To reproduce:
import json
from aws_lambda_powertools.tracing import Tracer
tracer = Tracer()
@tracer.capture_method
def func_1():
return 1
@tracer.capture_method
def func_2():
return 2
@tracer.capture_method
def sums_values():
return func_1() + func_2() # Calling a decorated function from another decorated function causes an error.
def lambda_handler(event, context):
val = sums_values()
return {
"statusCode": 200,
"body": json.dumps({
"message": val,
}),
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Triage