首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >google-api-python-client因为OAuth2而崩溃?

google-api-python-client因为OAuth2而崩溃?
EN

Stack Overflow用户
提问于 2016-02-19 14:03:38
回答 1查看 421关注 0票数 0

我正在尝试使用Python中的Google Api客户端检查bigquery中是否存在某个数据集。它一直在工作,直到最后一次更新,我得到了这个奇怪的错误,我不知道如何修复:

代码语言:javascript
复制
Traceback (most recent call last):
  File "/root/miniconda/lib/python2.7/site-packages/dsUtils/bq_utils.py", line 106, in _get
    resp = bq_service.datasets().get(projectId=self.project_id, datasetId=self.id).execute(num_retries=2)
  File "/root/miniconda/lib/python2.7/site-packages/oauth2client/util.py", line 140, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/root/miniconda/lib/python2.7/site-packages/googleapiclient/http.py", line 755, in execute
    method=str(self.method), body=self.body, headers=self.headers)
  File "/root/miniconda/lib/python2.7/site-packages/googleapiclient/http.py", line 93, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "/root/miniconda/lib/python2.7/site-packages/oauth2client/client.py", line 598, in new_request
    self._refresh(request_orig)
  File "/root/miniconda/lib/python2.7/site-packages/oauth2client/client.py", line 864, in _refresh
    self._do_refresh_request(http_request)
  File "/root/miniconda/lib/python2.7/site-packages/oauth2client/client.py", line 891, in _do_refresh_request
    body = self._generate_refresh_request_body()
  File "/root/miniconda/lib/python2.7/site-packages/oauth2client/client.py", line 1597, in _generate_refresh_req
uest_body
    assertion = self._generate_assertion()
  File "/root/miniconda/lib/python2.7/site-packages/oauth2client/service_account.py", line 263, in _generate_ass
ertion
    key_id=self._private_key_id)
  File "/root/miniconda/lib/python2.7/site-packages/oauth2client/crypt.py", line 97, in make_signed_jwt
    signature = signer.sign(signing_input)
  File "/root/miniconda/lib/python2.7/site-packages/oauth2client/_pycrypto_crypt.py", line 101, in sign
    return PKCS1_v1_5.new(self._key).sign(SHA256.new(message))
  File "/root/miniconda/lib/python2.7/site-packages/Crypto/Signature/PKCS1_v1_5.py", line 112, in sign
    m = self._key.decrypt(em)
  File "/root/miniconda/lib/python2.7/site-packages/Crypto/PublicKey/RSA.py", line 174, in decrypt
    return pubkey.pubkey.decrypt(self, ciphertext)
  File "/root/miniconda/lib/python2.7/site-packages/Crypto/PublicKey/pubkey.py", line 93, in decrypt
    plaintext=self._decrypt(ciphertext)
  File "/root/miniconda/lib/python2.7/site-packages/Crypto/PublicKey/RSA.py", line 235, in _decrypt
    r = getRandomRange(1, self.key.n-1, randfunc=self._randfunc)
  File "/root/miniconda/lib/python2.7/site-packages/Crypto/Util/number.py", line 123, in getRandomRange
    value = getRandomInteger(bits, randfunc)
  File "/root/miniconda/lib/python2.7/site-packages/Crypto/Util/number.py", line 104, in getRandomInteger
    S = randfunc(N>>3)
  File "/root/miniconda/lib/python2.7/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 202, in read
    return self._singleton.read(bytes)
  File "/root/miniconda/lib/python2.7/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 178, in read
    return _UserFriendlyRNG.read(self, bytes)
  File "/root/miniconda/lib/python2.7/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 137, in read
    self._check_pid()
  File "/root/miniconda/lib/python2.7/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 153, in _check_pid
    raise AssertionError("PID check failed. RNG must be re-initialized after fork(). Hint: Try Random.atfork()")
AssertionError: PID check failed. RNG must be re-initialized after fork(). Hint: Try Random.atfork()

有没有人知道什么是强迫症?

请注意,我在使用GCStorage等其他bricks时也会遇到此错误。

另请注意,我使用以下命令加载我的Google凭据:

代码语言:javascript
复制
from oauth2client.client import GoogleCredentials

def get_credentials(credentials_path):  #my json credentials path
    logger.info('Getting credentials...')
    try:
        os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credentials_path
        credentials = GoogleCredentials.get_application_default()
        return credentials
    except Exception as e:
        raise e

因此,如果有人知道使用我的json服务帐户文件加载我的google凭据的更好方法,并且可以避免错误,请告诉我。

EN

回答 1

Stack Overflow用户

发布于 2016-02-20 01:28:56

错误似乎出现在PyCrypto模块中,该模块似乎被谷歌的OAuth2实现在幕后使用。如果您的代码在某个时刻调用os.fork(),则可能需要在以后的父进程和子进程中调用Crypto.Random.atfork(),以便更新模块的内部状态。

在这里查找PyCrypto文档;搜索"atfork“以获取更多信息:https://github.com/dlitz/pycrypto

这个问题和答案可能也是相关的:PyCrypto : AssertionError("PID check failed. RNG must be re-initialized after fork(). Hint: Try Random.atfork()")

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35498370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档