Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
Monkeypatch sphinx socket timeout to 5s
Browse files Browse the repository at this point in the history
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 client.py 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
willkg committed Aug 13, 2012
1 parent e26a8ea commit 9d1d1ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 5 additions & 0 deletions apps/search/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
4 changes: 0 additions & 4 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9d1d1ae

Please sign in to comment.