Skip to content
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

Merged
merged 4 commits into from
Mar 30, 2017

Conversation

lukesneeringer
Copy link
Contributor

Closes #3211.

@lukesneeringer lukesneeringer self-assigned this Mar 28, 2017
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 28, 2017
@@ -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.

Copy link
Contributor

@dhermes dhermes left a 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.

@@ -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.

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.

@lukesneeringer
Copy link
Contributor Author

lukesneeringer commented Mar 28, 2017

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.

The teeny performance hit would be to create a new string at module import for everyone else.

@dhermes
Copy link
Contributor

dhermes commented Mar 28, 2017

Feel free to merge once you get CI green

@lukesneeringer lukesneeringer merged commit 0faaf54 into googleapis:master Mar 30, 2017
@lukesneeringer lukesneeringer deleted the issue-3211 branch March 30, 2017 14:51
dhermes added a commit to dhermes/google-cloud-python that referenced this pull request Mar 30, 2017
Issue caused by two unrelated PRs merging in close
proximity: googleapis#3235 and googleapis#3230.
lukesneeringer pushed a commit that referenced this pull request Mar 30, 2017
Issue caused by two unrelated PRs merging in close
proximity: #3235 and #3230.
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
Issue caused by two unrelated PRs merging in close
proximity: googleapis#3235 and googleapis#3230.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants