locks for searches
This commit is contained in:
parent
845b7a7ce2
commit
206dd308c7
@ -5,6 +5,8 @@ import analysis.archive ## circular...
|
||||
import analysis.query
|
||||
import analysis.format
|
||||
|
||||
import threading
|
||||
|
||||
class Archive():
|
||||
|
||||
def __init__(self, archives_dir=None):
|
||||
@ -16,6 +18,9 @@ class Archive():
|
||||
|
||||
self.loaded = False
|
||||
|
||||
self.lock_search = threading.Lock()
|
||||
self.lock_threads_ranking = threading.Lock()
|
||||
|
||||
def load(self, archive_name=None):
|
||||
|
||||
if archive_name == None:
|
||||
@ -59,6 +64,8 @@ class Archive():
|
||||
|
||||
def search(self, keyword, field='content', min_hits=0):
|
||||
|
||||
with self.lock_search:
|
||||
|
||||
search_results = { "keyword": keyword, "field": field, "archive": self.archive_name, "results": [] }
|
||||
|
||||
for k, v in sorted(self.archive.items(), key=get_key, reverse=True):
|
||||
@ -83,6 +90,8 @@ class Archive():
|
||||
|
||||
def threads_ranking(self, rank=5):
|
||||
|
||||
with self.lock_threads_ranking:
|
||||
|
||||
search_results = { "keyword": "thread ranking", "field": "ranking", "archive": self.archive_name, "results": [] }
|
||||
|
||||
a = analysis.archive.Archive(self)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user