-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make clients explicitly unpickleable. #3230
Conversation
@@ -14,6 +14,8 @@ | |||
|
|||
"""Base classes for client used to interact with Google Cloud APIs.""" | |||
|
|||
from pickle import PicklingError |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Content LGTM. Style nit in the string creation. (I would say it's a "teeny performance hit" to create a new string at every use, but that would be wrong since the string is created right before program exit.)
@@ -14,6 +14,8 @@ | |||
|
|||
"""Base classes for client used to interact with Google Cloud APIs.""" | |||
|
|||
from pickle import PicklingError |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
core/google/cloud/client.py
Outdated
@@ -126,6 +128,14 @@ def __init__(self, credentials=None, http=None): | |||
credentials, self.SCOPE) | |||
self._http_internal = http | |||
|
|||
def __getstate__(self): | |||
"""Explicitly state that clients are not pickleable.""" | |||
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
core/google/cloud/client.py
Outdated
raise PicklingError('\n'.join([ | ||
'Pickling client objects is explicitly not supported.', | ||
'Clients have non-trivial state that is local and unpickleable.', | ||
])) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
The teeny performance hit would be to create a new string at module import for everyone else. |
Feel free to merge once you get CI green |
Issue caused by two unrelated PRs merging in close proximity: googleapis#3235 and googleapis#3230.
Issue caused by two unrelated PRs merging in close proximity: googleapis#3235 and googleapis#3230.
Closes #3211.