In a lot of swh services, there's a common reuse pattern for db interactions: initialize a postgresql connection, define a custom cursor object that reconnects (with retries) to the database, some commit/rollback wrappers, an autocommit() decorator and a cursor= parameter to pass transactions through subfunctions.
All this behavior should be normalized, and then factored out in swh.core. This could also be the occasion to find genericity patterns and adapt the base class for multiple types of usages, and to add context manager semantics to have a better unified way to do graceful teardown, for instance in database unit tests.
These are the places where I saw these common patterns (non exhaustive, You Can Help By Expanding It™):
- swh.indexer.storage.db (-> it does inherit from swh.storage.db.BaseDb though)