The Blob.exists() method does not work when run within a Batch context. The normal behavior of exists() is to return True unless a NotFound exception occurs. Within the Batch context the exception seems to be suppressed and the function returns True. After leaving the Batch context, an Exception is then thrown.
This is how I expected to be able to use the exists() function:
blobs = [storage.blob.Blob(path, bucket) for path in paths]
with client.batch():
bools = [blob.exists() for blob in blobs]
Without the Batch contextmanager this code works, if inefficiently. With the Batch contextmanager the code returns all Trues and throws an exception when leaving the context.
This behavior seems unintuitive to me. Please let me know if the API is meant to be used differently. If it is meant to be used as in the provided code sample, I'd be happy to attempt a fix if one of the maintainers could point me in the right direction.
Environment configuration just in case:
- macOS 10.13.3
- Python 3.6.5
- google-cloud-storage==1.8.0
The
Blob.exists()method does not work when run within a Batch context. The normal behavior ofexists()is to return True unless aNotFoundexception occurs. Within the Batch context the exception seems to be suppressed and the function returns True. After leaving the Batch context, an Exception is then thrown.This is how I expected to be able to use the
exists()function:Without the
Batchcontextmanager this code works, if inefficiently. With theBatchcontextmanager the code returns allTrues and throws an exception when leaving the context.This behavior seems unintuitive to me. Please let me know if the API is meant to be used differently. If it is meant to be used as in the provided code sample, I'd be happy to attempt a fix if one of the maintainers could point me in the right direction.
Environment configuration just in case: