Some solr queries can be really slow. We should have a configurable timeout on our solr queries so the original web request stops after several seconds and doesn't jam things up.
Make sure this doesn't negatively impact add/remove artifact tasks that could be huge and take a long time (which is ok). Do we have other solr read queries that don't originate from web requests and should be given long timeouts?
allura:cj/5697
One line uses
with_timeout
which isn't right.Overall, it's not pretty, but that's more pysolr's fault than ours. Could
search_artifact
use thesearch()
method too, so the if stmt doesn't have to be duplicated?It could not, as
search()
is wrapped with@try_solr
.As for making it prettier, I could make our subclass redefine
search()
to accept a timeout instead of requiring it at__init__
by temporarily settingself.timeout
before callingsuper
, but I was mildly concerned about potential concurrency issues.Alternatively / additionally, we could make the default value be the common case (short timeout) so that we don't have to manually specify it every time, but I went with default as long to be safer if I missed any cases (scripts).
with_timeout
fix pushedConsolidation of Solr error handling added.