Browse files

Monkeypatch sphinx socket timeout to 5s

Input gets a lot of timeouts from Sphinx. This monkeypatches the
K_TIMEOUT "constant" from 1s to 5s which should reduce the number of
timeouts we get. This reworks the TIMEOUT change from 0e4437f.  The
previous change chnaged sphinxapi.TIMEOUT rather than
sphinxapi.K_TIMEOUT so it didn't have an effect on the actual
timeout. However, it allowed us to set the timeout based on a
SPHINX_TIMEOUT setting in settings.

I also moved the monkeypatch to which is the only thing
that uses the sphinxapi lib. It's more appropriate there.

Note: This is a stop-gap while we're rewriting the system.
  • Loading branch information...
1 parent e26a8ea commit 9d1d1aefc59b74728c2152c2cebff87009fa9969 Will Kahn-Greene committed Aug 13, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −0 apps/search/
  2. +0 −4
5 apps/search/
@@ -22,6 +22,11 @@
import sphinxapi as sphinx
+# Monkey-patch sphinx socket timeout. Default to 5s (instead of 1s)
+# but allow it to be overridden by SPHINX_TIMEOUT setting in settings.
+sphinx.K_TIMEOUT = getattr(settings, 'SPHINX_TIMEOUT', 5)
SPHINX_HARD_LIMIT = 1000 # A hard limit that sphinx imposes.
@@ -4,12 +4,8 @@
from django.shortcuts import redirect
import jingo
-import sphinxapi
from django_arecibo.tasks import post as arecibo_post
-sphinxapi.TIMEOUT = getattr(settings, 'SPHINX_TIMEOUT', 1)
def _error_page(request, status):
"""Render error pages with jinja2."""
return jingo.render(request, '%d.html' % status, status=status)

0 comments on commit 9d1d1ae

Please sign in to comment.