From 8c0fe97edf5737fa5f6edc501f8bd57fdf49781f Mon Sep 17 00:00:00 2001 From: Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> Date: Tue, 21 Sep 2021 13:41:35 +0100 Subject: Only run compressor if run_background_tasks is true --- synapse/util/state_compressor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/synapse/util/state_compressor.py b/synapse/util/state_compressor.py index eb4a895b34..0bc8f91ff6 100644 --- a/synapse/util/state_compressor.py +++ b/synapse/util/state_compressor.py @@ -11,6 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from typing import TYPE_CHECKING + from synapse.logging.context import defer_to_thread from synapse.metrics.background_process_metrics import run_as_background_process @@ -19,12 +21,15 @@ try: except ImportError: state_compressor = None +if TYPE_CHECKING: + from synapse.server import HomeServer + -def setup_state_compressor(hs): +def setup_state_compressor(hs: "HomeServer"): """Schedules the state compressor to run regularly""" # Return if cannot import auto_compressor - if not state_compressor: + if not state_compressor or not hs.config.workers.run_background_tasks: return # Return if compressor isn't enabled -- cgit 1.4.1