Skip to content

Support timeout = 0 in search query #2934

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

Merged
merged 12 commits into from
Sep 14, 2023
Merged
2 changes: 1 addition & 1 deletion redis/commands/search/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _get_args_tags(self):
args += self._ids
if self._slop >= 0:
args += ["SLOP", self._slop]
if self._timeout:
if self._timeout is not None:
args += ["TIMEOUT", self._timeout]
if self._in_order:
args.append("INORDER")
Expand Down
2 changes: 2 additions & 0 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,8 @@ def test_withsuffixtrie(client: redis.Redis):
def test_query_timeout(r: redis.Redis):
q1 = Query("foo").timeout(5000)
assert q1.get_args() == ["foo", "TIMEOUT", 5000, "LIMIT", 0, 10]
q1 = Query("foo").timeout(0)
assert q1.get_args() == ["foo", "TIMEOUT", 0, "LIMIT", 0, 10]
q2 = Query("foo").timeout("not_a_number")
with pytest.raises(redis.ResponseError):
r.ft().search(q2)