GeezerVison is showing github.com — Consider allowing storage.bucket.Bucket.delete_key to silently fail if user requests it · Issue #160 · googleapis/google-cloud-python
Consider allowing storage.bucket.Bucket.delete_key to silently fail if user requests it #160Labels 🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged. DescriptionFrom TODO:
# TODO: Should we accept a 'silent' param here to not raise an exception?
See storage.bucket.Bucket.delete_key for relevant code and #146 for some context.
git blame output
b7f1b774 (JJ Geewax 2014-01-29 18:02:29 -0500 158) # TODO: Should we accept a 'silent' param here to not raise an exception?
Activitytseaver commented on Sep 23, 2014 -1: users who want to silence the exception can use 'try: ... except Blah: pass' dhermes commented on Sep 23, 2014 ContributorAuthor More actions I tend to agree with you but will play devil's advocate anyhow.
I think JJ was targeting the case that DELETE is sent for an object that doesn't exist. I'd imagine in parallel code this could cause an issue if two deletes are sent.
From an App Engine remote API session using the datastore:
>>> from google.appengine.ext import ndb
>>> k = ndb.Key('A', 'b')
>>> print k
Key('A', 'b')
>>> print k.get()
None
>>> print k.delete()
Noneadded this to the This milestone has been deleted milestone on Sep 24, 2014tseaver commented on Oct 29, 2014 The API spec doesn't state it, but I assume that it returns a 404 in the case that the key maps to a non-existent object. I still think propagating the storage.exceptions.NotFoundError raised by storage.connection.Connection.api_request is the more Pythonic thing to do. tseaver commented on Oct 29, 2014 If #312 lands, it could be the resolution for this issue as well: users who want to delete without raising could use bucket.delete_keys([key]) instead of bucket.delete_key(key), and potentially check the result. tseaver commented on Oct 31, 2014 @silvolu I would recommend closing here: users who don't care about the NotFoundError can call bucket.delete_keys([key]) omitting the on_error callback added in #312. silvolu commented on Nov 3, 2014 Sounds good, should we add something to the docs for delete_keys to make it clear, e.g.: "You can use this method with a single key if you want to suppress any NotFoundError, by omitting the on_error callback" ? tseaver commented on Nov 3, 2014 Actually, it would need to be different, since omitting the callback (now) causes the error to be raised. To suppress the error, you would need to call bucket.delete_keys([key], on_error=lambda key: pass). silvolu commented on Nov 3, 2014 Oh, ok. Should we add that to the doc? Might be not immediately clear. added a commit that references this issue on Nov 3, 2014This issue will close once commit 2b73c7b is merged into the 'main' branch.2b73c7b
MetadataMetadata🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged. DevelopmentNo branches or pull requestsIssue actions
|