X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/18e520abab50a7e37eff7b09b9754ed32899811b..8658102277980ea8e8e53a953e7c2f5fedf8de16:/apps/catalogue/models.py diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 3db237e3c..1a2e8f86f 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -626,8 +626,19 @@ class Book(models.Model): return result.wait() def search_index(self): - with search.ReusableIndex() as idx: + if settings.SEARCH_INDEX_PARALLEL: + if instance(settings.SEARCH_INDEX_PARALLEL, int): + idx = search.ReusableIndex(threads=4) + else: + idx = search.ReusableIndex() + else: + idx = search.Index() + + idx.open() + try: idx.index_book(self) + finally: + idx.close() @classmethod def from_xml_file(cls, xml_file, **kwargs):