File tree Expand file tree Collapse file tree 2 files changed +20
-8
lines changed
piccolo/apps/asgi/commands/templates/starlette Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -76,11 +76,17 @@ async def delete_task(task_id: int):
7676
7777@app.on_event("startup")
7878async def open_database_connection_pool():
79- engine = engine_finder()
80- await engine.start_connection_pool()
79+ try:
80+ engine = engine_finder()
81+ await engine.start_connection_pool()
82+ except Exception:
83+ print("Unable to connect to the database")
8184
8285
8386@app.on_event("shutdown")
8487async def close_database_connection_pool():
85- engine = engine_finder()
86- await engine.close_connection_pool()
88+ try:
89+ engine = engine_finder()
90+ await engine.close_connection_pool()
91+ except Exception:
92+ print("Unable to connect to the database")
Original file line number Diff line number Diff line change @@ -29,11 +29,17 @@ app = Starlette(
2929
3030@app.on_event("startup")
3131async def open_database_connection_pool():
32- engine = engine_finder()
33- await engine.start_connection_pool()
32+ try:
33+ engine = engine_finder()
34+ await engine.start_connection_pool()
35+ except Exception:
36+ print("Unable to connect to the database")
3437
3538
3639@app.on_event("shutdown")
3740async def close_database_connection_pool():
38- engine = engine_finder()
39- await engine.close_connection_pool()
41+ try:
42+ engine = engine_finder()
43+ await engine.close_connection_pool()
44+ except Exception:
45+ print("Unable to connect to the database")
You can’t perform that action at this time.
0 commit comments