diff options
author | Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> | 2021-09-21 13:41:35 +0100 |
---|---|---|
committer | Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> | 2021-09-21 13:42:21 +0100 |
commit | 8c0fe97edf5737fa5f6edc501f8bd57fdf49781f (patch) | |
tree | 64ab56237d457e8c52bbada4d1dc8b89615e179e | |
parent | Run linters (diff) | |
download | synapse-8c0fe97edf5737fa5f6edc501f8bd57fdf49781f.tar.xz |
Only run compressor if run_background_tasks is true
-rw-r--r-- | synapse/util/state_compressor.py | 9 |
1 files 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 |