Browse Source

add new SEARCH_BACKEND_TIMEOUT config option defaulted to 90sec

Nick Sweeting 4 years ago
parent
commit
32764347ce
2 changed files with 3 additions and 2 deletions
  1. 1 0
      archivebox/config.py
  2. 2 2
      archivebox/search/backends/ripgrep.py

+ 1 - 0
archivebox/config.py

@@ -157,6 +157,7 @@ CONFIG_SCHEMA: Dict[str, ConfigDefaultDict] = {
         # SONIC
         # SONIC
         'SONIC_COLLECTION':         {'type': str,   'default': 'archivebox'},
         'SONIC_COLLECTION':         {'type': str,   'default': 'archivebox'},
         'SONIC_BUCKET':             {'type': str,   'default': 'snapshots'},
         'SONIC_BUCKET':             {'type': str,   'default': 'snapshots'},
+        'SEARCH_BACKEND_TIMEOUT':   {'type': int,   'default': 90},
     },
     },
 
 
     'DEPENDENCY_CONFIG': {
     'DEPENDENCY_CONFIG': {

+ 2 - 2
archivebox/search/backends/ripgrep.py

@@ -2,7 +2,7 @@ import re
 from subprocess import run, PIPE
 from subprocess import run, PIPE
 from typing import List, Generator
 from typing import List, Generator
 
 
-from archivebox.config import ARCHIVE_DIR, RIPGREP_VERSION
+from archivebox.config import ARCHIVE_DIR, RIPGREP_VERSION, SEARCH_BACKEND_TIMEOUT
 from archivebox.util import enforce_types
 from archivebox.util import enforce_types
 
 
 RG_IGNORE_EXTENSIONS = ('css','js','orig','svg')
 RG_IGNORE_EXTENSIONS = ('css','js','orig','svg')
@@ -32,7 +32,7 @@ def search(text: str) -> List[str]:
     from core.models import Snapshot
     from core.models import Snapshot
 
 
     rg_cmd = ['rg', RG_ADD_TYPE, RG_IGNORE_ARGUMENTS, RG_DEFAULT_ARGUMENTS, RG_REGEX_ARGUMENT, text, str(ARCHIVE_DIR)]
     rg_cmd = ['rg', RG_ADD_TYPE, RG_IGNORE_ARGUMENTS, RG_DEFAULT_ARGUMENTS, RG_REGEX_ARGUMENT, text, str(ARCHIVE_DIR)]
-    rg = run(rg_cmd, stdout=PIPE, stderr=PIPE, timeout=60)
+    rg = run(rg_cmd, stdout=PIPE, stderr=PIPE, timeout=SEARCH_BACKEND_TIMEOUT)
     file_paths = [p.decode() for p in rg.stdout.splitlines()]
     file_paths = [p.decode() for p in rg.stdout.splitlines()]
     timestamps = set()
     timestamps = set()
     for path in file_paths:
     for path in file_paths: