@@ -237,7 +237,7 @@ def parallel_bulk(client, actions, thread_count=4, chunk_size=500,
237237 pool .join ()
238238
239239def scan (client , query = None , scroll = '5m' , raise_on_error = True ,
240- preserve_order = False , size = 1000 , ** kwargs ):
240+ preserve_order = False , size = 1000 , request_timeout = None , ** kwargs ):
241241 """
242242 Simple abstraction on top of the
243243 :meth:`~elasticsearch.Elasticsearch.scroll` api - a simple iterator that
@@ -260,6 +260,7 @@ def scan(client, query=None, scroll='5m', raise_on_error=True,
260260 can be an extremely expensive operation and can easily lead to
261261 unpredictable results, use with caution.
262262 :arg size: size (per shard) of the batch send at each iteration.
263+ :arg request_timeout: explicit timeout for each call to ``scan``
263264
264265 Any additional keyword arguments will be passed to the initial
265266 :meth:`~elasticsearch.Elasticsearch.search` call::
@@ -275,7 +276,8 @@ def scan(client, query=None, scroll='5m', raise_on_error=True,
275276 body = query .copy () if query else {}
276277 body ["sort" ] = "_doc"
277278 # initial search
278- resp = client .search (body = query , scroll = scroll , size = size , ** kwargs )
279+ resp = client .search (body = query , scroll = scroll , size = size ,
280+ request_timeout = request_timeout , ** kwargs )
279281
280282 scroll_id = resp .get ('_scroll_id' )
281283 if scroll_id is None :
@@ -288,7 +290,7 @@ def scan(client, query=None, scroll='5m', raise_on_error=True,
288290 if first_run :
289291 first_run = False
290292 else :
291- resp = client .scroll (scroll_id , scroll = scroll )
293+ resp = client .scroll (scroll_id , scroll = scroll , request_timeout = request_timeout )
292294
293295 for hit in resp ['hits' ]['hits' ]:
294296 yield hit
0 commit comments