Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

feat: import CRAWLER_WORKERS from env_vars and simplify worker configuration

thiswillbeyourgithub (aider)661879fa2096
diff --git a/mwmbl/crawl.py b/mwmbl/crawl.py
index 37d8c05..c0c8356 100644
--- a/mwmbl/crawl.py
+++ b/mwmbl/crawl.py
@@ -9,6 +9,7 @@ import requests
from django.conf import settings
from redis import Redis
+from mwmbl.crawler.env_vars import CRAWLER_WORKERS
from mwmbl.rankeval.evaluation.remote_index import RemoteIndex
from mwmbl.redis_url_queue import RedisURLQueue
from mwmbl.tinysearchengine.indexer import TinyIndex, Document
@@ -42,12 +43,7 @@ url_queue = RedisURLQueue(redis, lambda: set())
def run():
- workers_str = os.environ.get("CRAWLER_WORKERS", "10")
- try:
- workers = int(workers_str)
- except ValueError:
- logger.error(f"Unable to parse CRAWLER_WORKERS environment variable (set to {workers_str})")
- return
+ workers = CRAWLER_WORKERS
batch_processes: list[Process] = []
for i in range(workers):
diff --git a/mwmbl/crawler/env_vars.py b/mwmbl/crawler/env_vars.py
index f9fcc56..2f507b8 100644
--- a/mwmbl/crawler/env_vars.py
+++ b/mwmbl/crawler/env_vars.py
@@ -18,6 +18,9 @@ MAX_NEW_LINKS = int(os.environ.get('MAX_NEW_LINKS', '50'))
MAX_EXTRA_LINKS = int(os.environ.get('MAX_EXTRA_LINKS', '50'))
MAX_SITE_URLS = int(os.environ.get('MAX_SITE_URLS', '100'))
+# Crawler worker configuration
+CRAWLER_WORKERS = int(os.environ.get('CRAWLER_WORKERS', '10'))
+
# Rate limiting configuration - delay in seconds between crawl requests to reduce bursting
CRAWL_DELAY_SECONDS = float(os.environ.get('CRAWL_DELAY_SECONDS', '0.0'))