Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix synapse failing to start when python module sqlite3 is not installed #12974

Closed
wants to merge 5 commits into from

Conversation

H-Shay
Copy link
Contributor

@H-Shay H-Shay commented Jun 7, 2022

This PR fixes a regression introduced 1.60.0 wherein synapse will refuse to start if the python module sqlite3 is not installed, even if Postgres is being used. Apparently some versions of python don't have sqlite3 available. This PR shifts the import statements behind a conditional guard. Fixes #12962. Reviewable commit-by-commit.

@H-Shay H-Shay requested a review from a team as a code owner June 7, 2022 04:18
@H-Shay H-Shay removed the request for review from a team June 7, 2022 04:25
@H-Shay H-Shay marked this pull request as draft June 7, 2022 04:25
@@ -15,6 +15,8 @@
import logging
from typing import TYPE_CHECKING, Any, Mapping, NoReturn, Optional, Tuple, cast

import psycopg2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this change in c92f2f7 as it was causing errors.

@H-Shay H-Shay marked this pull request as ready for review June 7, 2022 04:58
if isinstance(self.db_pool.engine, engines.PostgresEngine):
if isinstance(self.db_pool.engine, engines.postgres.PostgresEngine):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh bugger. I forgot that we use isinstance everywhere, which means that PostgresEngine and SqliteEngine need to be importable everywhere.

Argh. Maybe my advice in #12962 was wrong.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants