Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions knowledge_repo/app/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
LOCKED = CHECKED = '1'
UNLOCKED = '0'

sync_lock = multiprocessing.Lock()


def set_up_indexing_timers(app):
if not app.config['INDEXING_ENABLED']:
Expand All @@ -39,9 +41,12 @@ def index_watchdog(app):
def index_sync_loop(app):
current_app.db.engine.dispose()
while True:
with app.app_context():
update_index(check_timeouts=False)
time.sleep(app.config['INDEXING_INTERVAL'])
sync_lock.acquire()
try:
with app.app_context():
update_index(check_timeouts=False)
finally:
sync_lock.release()

app.index_watchdog = multiprocessing.Process(target=index_watchdog, args=(app,))
app.index_watchdog.start()
Expand Down