Skip to content

Commit

Permalink
Fix mangum db connection pool
Browse files Browse the repository at this point in the history
  • Loading branch information
ividito committed Jan 20, 2023
1 parent 6a790c3 commit 80ff31f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion raster_api/runtime/handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""AWS Lambda handler."""

import logging
import os
import asyncio

from mangum import Mangum
from src.app import app
Expand All @@ -10,7 +12,11 @@
logging.getLogger("mangum.http").setLevel(logging.ERROR)


handler = Mangum(app, lifespan="auto")
handler = Mangum(app, lifespan="off")

if "AWS_EXECUTION_ENV" in os.environ:
loop = asyncio.get_event_loop()
loop.run_until_complete(app.router.startup())

# Add tracing
handler.__name__ = "handler" # tracer requires __name__ to be set
Expand Down

0 comments on commit 80ff31f

Please sign in to comment.