Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Don't start background tasks for crawler

Daoud Clarkee788c9013b60
diff --git a/mwmbl/apps.py b/mwmbl/apps.py
index e955e76..ee16ae0 100644
--- a/mwmbl/apps.py
+++ b/mwmbl/apps.py
@@ -40,9 +40,9 @@ class MwmblConfig(AppConfig):
def ready(self):
create_index()
- if settings.SETUP_DATABASE:
+ if settings.HAS_DATABASE:
create_index_db()
- self._schedule_background_tasks()
+ self._schedule_background_tasks()
@staticmethod
def _schedule_background_tasks():
diff --git a/mwmbl/settings_common.py b/mwmbl/settings_common.py
index b5fec1d..98f99a6 100644
--- a/mwmbl/settings_common.py
+++ b/mwmbl/settings_common.py
@@ -196,7 +196,8 @@ BATCH_DIR_NAME = 'batches'
DATA_UPLOAD_MAX_NUMBER_FIELDS = None
-SETUP_DATABASE = True
+# Gates database initialisation and background task scheduling; False for the crawler and tests.
+HAS_DATABASE = True
SENTRY_DSN = os.environ.get("SENTRY_DSN")
diff --git a/mwmbl/settings_crawler.py b/mwmbl/settings_crawler.py
index 5892ae1..b9bd31c 100644
--- a/mwmbl/settings_crawler.py
+++ b/mwmbl/settings_crawler.py
@@ -16,4 +16,4 @@ NUM_URLS_IN_BLOOM_FILTER = 10_000_000
DOMAIN_LINKS_BLOOM_FILTER_PATH = str(Path(DATA_PATH) / "links_{domain_group}.bloom")
NUM_DOMAINS_IN_BLOOM_FILTER = 100_000
-SETUP_DATABASE = False
+HAS_DATABASE = False
diff --git a/mwmbl/settings_test.py b/mwmbl/settings_test.py
index 7a6fa20..f23178b 100644
--- a/mwmbl/settings_test.py
+++ b/mwmbl/settings_test.py
@@ -1,7 +1,6 @@
from mwmbl.settings_dev import *
-# Disable the legacy psycopg2 index-DB setup for testing
-SETUP_DATABASE = False
+HAS_DATABASE = False
# PostgreSQL is required for ArrayField.
# Set DATABASE_URL in the environment before running tests, e.g.:
diff --git a/test/test_crawl_functional.py b/test/test_crawl_functional.py
index ee35c0a..5349663 100644
--- a/test/test_crawl_functional.py
+++ b/test/test_crawl_functional.py
@@ -37,7 +37,7 @@ def mock_settings(temp_data_path):
with override_settings(
DATA_PATH=str(temp_data_path),
REDIS_URL="redis://localhost:6379",
- SETUP_DATABASE=False, # Disable database setup for testing
+ HAS_DATABASE=False,
NUM_PAGES=10 # Small number for testing
):
yield