Use dict.popitem when we know the dict only has one key
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from itertools import islice, chain
|
||||
from itertools import islice
|
||||
from operator import methodcaller
|
||||
try:
|
||||
from itertools import imap as map
|
||||
@@ -106,7 +106,7 @@ def streaming_bulk(client, actions, chunk_size=500, raise_on_error=False, expand
|
||||
resp = client.bulk(bulk_actions, **kwargs)
|
||||
|
||||
# go through request-reponse pairs and detect failures
|
||||
for op_type, item in chain.from_iterable(map(methodcaller('items'), resp['items'])):
|
||||
for op_type, item in map(methodcaller('popitem'), resp['items']):
|
||||
ok = item.get('ok')
|
||||
if not ok and raise_on_error:
|
||||
errors.append({op_type: item})
|
||||
|
||||
Reference in New Issue
Block a user