-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
@app.on_event("startup")
async def open_database_connection_pool():
engine = engine_finder()
await engine.start_connection_pool()
@app.on_event("shutdown")
async def close_database_connection_pool():
engine = engine_finder()
await engine.close_connection_pool()
This code is in many of the sample applications. The engine_finder() is typed as Engine, which is an abstract class. It doesn't however provide an (@abstract)method for start_connection_pool() and close_connection_pool(). These methods only exist in the concrete subclass for Postgres. Hence vscode/pylance complain about non-existing methods.
I can do a PR, but am unsure about best solution.
Personally I would add these methods as normal methods to the Engine class, just providing a colored_warning() that pooling is not implemented for the provided engine.
Alternatively all sample programs using the connection pool could be changed like:
@app.on_event("startup")
async def open_database_connection_pool():
engine = engine_finder()
if isinstance(engine, PostgresEngine):
await engine.start_connection_pool()
Metadata
Metadata
Assignees
Labels
No labels