Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_or_update_many(self, wire, *args_list):
keys = self.key_many(wire, *args_list)
miss_value = object()
results = yield from wire.storage.get_many(
keys, miss_value=miss_value)
miss_indices = []
for i, akr in enumerate(zip(args_list, keys, results)):
args, key, result = akr
if result is not miss_value:
continue
miss_indices.append(i)
new_results = yield from asyncio.gather(*(
fbase.execute_bulk_item(wire, args_list[i]) for i in miss_indices))
new_keys = [keys[i] for i in miss_indices]
yield from wire.storage.set_many(new_keys, new_results)
for new_i, old_i in enumerate(miss_indices):
results[old_i] = new_results[new_i]
return results
def execute_many(self, wire, *args_list):
return asyncio.gather(*(
fbase.execute_bulk_item(wire, args) for args in args_list))
def execute_many(self, wire, *args_list):
values = [fbase.execute_bulk_item(wire, args) for args in args_list]
return values
def get_or_update_many(self, wire, *args_list):
keys = self.key_many(wire, *args_list)
miss_value = object()
results = wire.storage.get_many(keys, miss_value=miss_value)
miss_indices = []
for i, akr in enumerate(zip(args_list, keys, results)):
args, key, result = akr
if result is not miss_value:
continue
miss_indices.append(i)
new_results = [
fbase.execute_bulk_item(wire, args_list[i]) for i in miss_indices]
new_keys = [keys[i] for i in miss_indices]
wire.storage.set_many(new_keys, new_results)
for new_i, old_i in enumerate(miss_indices):
results[old_i] = new_results[new_i]
return results