Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On ConnectionError, try to get protected corpora from cache #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
16 changes: 12 additions & 4 deletions korp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3579,11 +3579,19 @@ def get_protected_corpora(corpora):
# callbacks typically add protected corpora to an initially empty list
# On failure, consider all corpora protected
try:
protected = (korppluginlib.KorpCallbackPluginCaller
.filter_value_for_request("filter_protected_corpora",
protected))
protected = korppluginlib.KorpCallbackPluginCaller.filter_value_for_request(
"filter_protected_corpora", protected
)
except ConnectionError:
return corpora
# If we can't connect, trust the cache if available
with mc_pool.reserve() as mc:
result = mc.get("%s:info_%s" % (cache_prefix(), int(strict)))
if result:
return result["protected_corpora"]
else:
# If all else fails, consider evenrything protected.
# This will crash Korp until the PUB-authentication bug is fixed.
return corpora
return protected


Expand Down