【发布时间】:2019-03-16 08:58:09
【问题描述】:
我正在尝试将 python 服务器放在 Google Compute Engine 上的 VM 中,其持续时间超过 10 分钟(App Engine 中的服务时间限制)。我给你我的代码和输出:
from google.cloud import storage as gcs
from requests_toolbelt.adapters import appengine
appengine.monkeypatch()
def my_function(filename, stringdata):
# init client gcp
gcs_client = gcs.Client()
bucket = gcs_client.get_bucket(config["cloud_storage_segment"])
upload_blob_from_string(bucket, filename, stringdata)
输出告诉我:
文件 “/home/guillermo.diaz/.local/lib/python2.7/site-packages/flask/app.py”, 第 1994 行,在 call 中 return self.wsgi_app(environ, start_response)
文件“/home/user/.local/lib/python2.7/site-packages/flask/app.py”, 第 1985 行,在 wsgi_app 中 响应 = self.handle_exception(e)
文件“/home/user/.local/lib/python2.7/site-packages/flask/app.py”, 第 1540 行,在句柄异常中 reraise(exc_type, exc_value, tb)
文件“/home/user/.local/lib/python2.7/site-packages/flask/app.py”, 第 1982 行,在 wsgi_app 中 响应 = self.full_dispatch_request()
文件“/home/user/.local/lib/python2.7/site-packages/flask/app.py”, 第 1614 行,在 full_dispatch_request 中 rv = self.handle_user_exception(e)
文件“/home/user/.local/lib/python2.7/site-packages/flask/app.py”, 第 1517 行,在 handle_user_exception 中 reraise(exc_type, exc_value, tb)
文件“/home/user/.local/lib/python2.7/site-packages/flask/app.py”, 第 1612 行,在 full_dispatch_request 中 rv = self.dispatch_request()
文件“/home/user/.local/lib/python2.7/site-packages/flask/app.py”, 第 1598 行,在 dispatch_request 中 返回 self.view_functionsrule.endpoint
文件“/home/user/my_module/main.py”, 第 50 行,在 my_function 中 bucket = gcs_client.get_bucket(config["cloud_storage_segment"])
文件 "/home/user/.local/lib/python2.7/site-packages/google/cloud/storage/client.py", 第 225 行,在 get_bucket 中 bucket.reload(client=self)
文件“/home/user/.local/lib/python2.7/site-packages/google/cloud/storage/_helpers.py”, 第 108 行,在重新加载中 _target_object=self)
文件“/home/user/.local/lib/python2.7/site-packages/google/cloud/_http.py”, 第 290 行,在 api_request 中 headers=headers, target_object=_target_object)
文件“/home/user/.local/lib/python2.7/site-packages/google/cloud/_http.py”, 第 183 行,在 _make_request return self._do_request(method, url, headers, data, target_object) 文件 "/home/user/.local/lib/python2.7/site-packages/google/cloud/_http.py", 第 211 行,在 _do_request 返回 self.http.request(
文件“/home/user/.local/lib/python2.7/site-packages/google/cloud/_http.py”, 第 73 行,在 http 返回 self._client._http
文件“/home/user/.local/lib/python2.7/site-packages/google/cloud/client.py”, 第 151 行,在 _http 中 self._credentials))
文件“/home/user/.local/lib/python2.7/site-packages/google/auth/transport/requests.py”, 第 161 行,在 init 中 super(AuthorizedSession, self).init(**kwargs)
文件“/home/user/.local/lib/python2.7/site-packages/requests/sessions.py”, 第 396 行,在 init 中 self.mount('https://', HTTPAdapter())
文件“/home/user/.local/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.py”, 第 79 行,在 init 中 super(AppEngineAdapter, self).init(*args, **kwargs)
文件“/home/user/.local/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.py”, 第 60 行,在 init 中 super(AppEngineMROHack, self).init(*args, **kwargs)
文件“/home/user/.local/lib/python2.7/site-packages/requests/adapters.py”, 第 127 行,在 init 中 self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)
文件 "/home/user/.local/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.py", 第 82 行,在 init_poolmanager 中 self.poolmanager = _AppEnginePoolManager(self._validate_certificate)
文件“/home/user/.local/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.py”, 第 122 行,在 init 中 validate_certificate=validate_certificate)
文件“/home/user/.local/lib/python2.7/site-packages/urllib3/contrib/appengine.py”, 第 103 行,在 init 中 "URLFetch 在此环境中不可用。")
有人可以帮助我吗?感谢您的宝贵时间!
【问题讨论】:
标签: python google-app-engine google-cloud-storage google-compute-engine