generated from amazon-archives/__template_MIT-0
    
        
        - 
                Notifications
    You must be signed in to change notification settings 
- Fork 455
Open
Labels
feature-requestfeature requestfeature requesthelp wantedCould use a second pair of eyes/handsCould use a second pair of eyes/handson-holdThis item is on-hold and will be revisited in the futureThis item is on-hold and will be revisited in the future
Description
Use case
I would love to be able to use asynchronous Python with Powertools. I understand there is not as much need for it in a Lambda runtime as a Lambda (process) will handle only one event but I would still be able to use async-only libraries like encode/databases (with the likes of Neon) or simply reduce my execution time by utilizing asyncio.gather when doing concurrent waits for I/O operations.
Solution/User Experience
I imagine being able to use it similarly to what the GraphQL resolver does:
@app.get("/todos")
@tracer.capture_method
async def get_todos():
    todos: httpx.Response = httpx.get("https://jsonplaceholder.typicode.com/todos")
    todos.raise_for_status()
    return {"todos": todos.json()[:10]}
# You can continue to use other utilities just as before
@logger.inject_lambda_context(correlation_id_path=correlation_paths.API_GATEWAY_REST)
@tracer.capture_lambda_handler
def lambda_handler(event: dict, context: LambdaContext) -> dict:
    result = app.resolve(event, context)
    return asyncio.run(result)Alternative solutions
No response
Acknowledgment
- This feature request meets Powertools for AWS Lambda (Python) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET
gajda-w, piotrgrundas, DamianCzajkowski, KarolJagodzinski, akjanik and 21 more
Metadata
Metadata
Assignees
Labels
feature-requestfeature requestfeature requesthelp wantedCould use a second pair of eyes/handsCould use a second pair of eyes/handson-holdThis item is on-hold and will be revisited in the futureThis item is on-hold and will be revisited in the future
Type
Projects
Status
On hold