Details
Description
The docs don't mention that add_multi will raise KeyExistsError for the last already existing key, if any number of them already exist. If this is intentional behavior, mentioning it in the docs would be useful and that the KeyExistsError.all_results is where most people will need to look for the OperationResult list.
This behavior seems odd for the API. Assuming there is not a connection/server error, always returning the OperationResult dict would be more intuitive and avoid the code pattern of:
try:
results = bucket.add_multi(keys)
except KeyExistsError as e:
- ignore exception because I'm going to process the results anyway
results = e.all_results
- now process/verify 'results'
—
If add_multi always returned an OperationResult dict, the code would simply be:
results = bucket.add_multi(keys)
- process/verify 'results' without the unnecessary exception