diff options
author | Travis Ralston <travpc@gmail.com> | 2018-02-01 18:05:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-01 18:05:47 -0700 |
commit | 6e87b34f7b7c595d4e5b96e4a0281b8327e5b8b7 (patch) | |
tree | 35701fcc0456593d736a3405f72a5dfd624b1cad /synapse/server.py | |
parent | pep8 (diff) | |
parent | Merge pull request #2837 from matrix-org/rav/fix_quarantine_media (diff) | |
download | synapse-6e87b34f7b7c595d4e5b96e4a0281b8327e5b8b7.tar.xz |
Merge branch 'develop' into travis/admin-list-media
Diffstat (limited to 'synapse/server.py')
-rw-r--r-- | synapse/server.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/server.py b/synapse/server.py index 99693071b6..ff8a8fbc46 100644 --- a/synapse/server.py +++ b/synapse/server.py @@ -307,6 +307,23 @@ class HomeServer(object): **self.db_config.get("args", {}) ) + def get_db_conn(self, run_new_connection=True): + """Makes a new connection to the database, skipping the db pool + + Returns: + Connection: a connection object implementing the PEP-249 spec + """ + # Any param beginning with cp_ is a parameter for adbapi, and should + # not be passed to the database engine. + db_params = { + k: v for k, v in self.db_config.get("args", {}).items() + if not k.startswith("cp_") + } + db_conn = self.database_engine.module.connect(**db_params) + if run_new_connection: + self.database_engine.on_new_connection(db_conn) + return db_conn + def build_media_repository_resource(self): # build the media repo resource. This indirects through the HomeServer # to ensure that we only have a single instance of |