Skip to content

Commit

Permalink
Moved validating timeout to timeout()
Browse files Browse the repository at this point in the history
Raise the exception when the timeout is set instead of when the query is performed
  • Loading branch information
meiravgri committed Sep 12, 2023
1 parent 25d4ddf commit 7a020bd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions redis/commands/search/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ def slop(self, slop):

def timeout(self, timeout):
"""overrides the timeout parameter of the module"""
self._timeout = timeout
if isinstance(timeout, int) and timeout >= 0:
self._timeout = timeou
else:
raise AttributeError("TIMEOUT requires a non negative integer.")
return self

def in_order(self):
Expand Down Expand Up @@ -194,10 +197,8 @@ def _get_args_tags(self):
args += self._ids
if self._slop >= 0:
args += ["SLOP", self._slop]
if isinstance(self._timeout, int) and self._timeout >= 0:
if self._timeout is not None:
args += ["TIMEOUT", self._timeout]
else:
raise AttributeError("TIMEOUT requires a non negative integer.")
if self._in_order:
args.append("INORDER")
if self._return_fields:
Expand Down

0 comments on commit 7a020bd

Please sign in to comment.