Skip to content

Commit 7a020bd

Browse files
authored
Moved validating timeout to timeout()
Raise the exception when the timeout is set instead of when the query is performed
1 parent 25d4ddf commit 7a020bd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: redis/commands/search/query.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ def slop(self, slop):
134134

135135
def timeout(self, timeout):
136136
"""overrides the timeout parameter of the module"""
137-
self._timeout = timeout
137+
if isinstance(timeout, int) and timeout >= 0:
138+
self._timeout = timeou
139+
else:
140+
raise AttributeError("TIMEOUT requires a non negative integer.")
138141
return self
139142

140143
def in_order(self):
@@ -194,10 +197,8 @@ def _get_args_tags(self):
194197
args += self._ids
195198
if self._slop >= 0:
196199
args += ["SLOP", self._slop]
197-
if isinstance(self._timeout, int) and self._timeout >= 0:
200+
if self._timeout is not None:
198201
args += ["TIMEOUT", self._timeout]
199-
else:
200-
raise AttributeError("TIMEOUT requires a non negative integer.")
201202
if self._in_order:
202203
args.append("INORDER")
203204
if self._return_fields:

0 commit comments

Comments
 (0)