Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用google api python客户端拉超时_Python_Python 2.7_Ssl_Httplib2_Google Cloud Pubsub - Fatal编程技术网

使用google api python客户端拉超时

使用google api python客户端拉超时,python,python-2.7,ssl,httplib2,google-cloud-pubsub,Python,Python 2.7,Ssl,Httplib2,Google Cloud Pubsub,我正在尝试设置一个用户定义的消息拉取超时,其“ReturnInstant”=False: PUBSUB_SCOPES = ['https://www.googleapis.com/auth/pubsub'] credentials = oauth2client.GoogleCredentials.get_application_default() if credentials.create_scoped_required(): credentials =

我正在尝试设置一个用户定义的消息拉取超时,其“ReturnInstant”=False:

    PUBSUB_SCOPES = ['https://www.googleapis.com/auth/pubsub']

    credentials = oauth2client.GoogleCredentials.get_application_default()
    if credentials.create_scoped_required():
        credentials = credentials.create_scoped(PUBSUB_SCOPES)

    http = httplib2.Http(timeout=timeout)
    credentials.authorize(http)

    return discovery.build('pubsub', 'v1', http=http)
当超时时间<90秒时,我会出现以下错误:

resp = client.projects().subscriptions().pull(subscription=subscription, body=body).execute()
  File "venv\lib\site-packages\oauth2client\util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "venv\lib\site-packages\googleapiclient\http.py", line 755, in execute
    method=str(self.method), body=self.body, headers=self.headers)
  File "venv\lib\site-packages\googleapiclient\http.py", line 93, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "venv\lib\site-packages\oauth2client\client.py", line 622, in new_request
    redirections, connection_type)
  File "venv\lib\site-packages\httplib2\__init__.py", line 1609, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "venv\lib\site-packages\httplib2\__init__.py", line 1351, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "venv\lib\site-packages\httplib2\__init__.py", line 1307, in _conn_request
    response = conn.getresponse()
  File "C:\python27\Lib\httplib.py", line 1074, in getresponse
    response.begin()
  File "C:\python27\Lib\httplib.py", line 415, in begin
    version, status, reason = self._read_status()
  File "C:\python27\Lib\httplib.py", line 371, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "C:\python27\Lib\socket.py", line 476, in readline
    data = self._sock.recv(self._rbufsize)
  File "C:\python27\Lib\ssl.py", line 714, in recv
    return self.read(buflen)
  File "C:\python27\Lib\ssl.py", line 608, in read
    v = self._sslobj.read(len or 1024)
SSLError: ('The read operation timed out',)

谢谢。

不幸的是,这些客户端库不支持将超时值转发到服务器;但是,我们有,它正确地将截止日期传递给服务器

作为当前库的一种变通方法,可以使用returninstallent=true,也可以将截止时间设置为大于90秒,正如您的问题所暗示的那样