I am trying to put a python server in a VM on Google Compute Engine that its duration is more than 10 minutes (time limit in App Engine for a service). I give you my code and the output:
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)
The output says me this:
File "/home/guillermo.diaz/.local/lib/python2.7/site-packages/flask/app.py", line 1994, in call return self.wsgi_app(environ, start_response)
File "/home/user/.local/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app response = self.handle_exception(e)
File "/home/user/.local/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception reraise(exc_type, exc_value, tb)
File "/home/user/.local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app response = self.full_dispatch_request()
File "/home/user/.local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e)
File "/home/user/.local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb)
File "/home/user/.local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request rv = self.dispatch_request()
File "/home/user/.local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request return self.view_functionsrule.endpoint
File "/home/user/my_module/main.py", line 50, in my_function bucket = gcs_client.get_bucket(config["cloud_storage_segment"])
File "/home/user/.local/lib/python2.7/site-packages/google/cloud/storage/client.py", line 225, in get_bucket bucket.reload(client=self)
File "/home/user/.local/lib/python2.7/site-packages/google/cloud/storage/_helpers.py", line 108, in reload _target_object=self)
File "/home/user/.local/lib/python2.7/site-packages/google/cloud/_http.py", line 290, in api_request headers=headers, target_object=_target_object)
File "/home/user/.local/lib/python2.7/site-packages/google/cloud/_http.py", line 183, in _make_request return self._do_request(method, url, headers, data, target_object) File "/home/user/.local/lib/python2.7/site-packages/google/cloud/_http.py", line 211, in _do_request return self.http.request(
File "/home/user/.local/lib/python2.7/site-packages/google/cloud/_http.py", line 73, in http return self._client._http
File "/home/user/.local/lib/python2.7/site-packages/google/cloud/client.py", line 151, in _http self._credentials))
File "/home/user/.local/lib/python2.7/site-packages/google/auth/transport/requests.py", line 161, in init super(AuthorizedSession, self).init(**kwargs)
File "/home/user/.local/lib/python2.7/site-packages/requests/sessions.py", line 396, in init self.mount('https://', HTTPAdapter())
File "/home/user/.local/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.py", line 79, in init super(AppEngineAdapter, self).init(*args, **kwargs)
File "/home/user/.local/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.py", line 60, in init super(AppEngineMROHack, self).init(*args, **kwargs)
File "/home/user/.local/lib/python2.7/site-packages/requests/adapters.py", line 127, in init self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)
File "/home/user/.local/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.py", line 82, in init_poolmanager self.poolmanager = _AppEnginePoolManager(self._validate_certificate)
File "/home/user/.local/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.py", line 122, in init validate_certificate=validate_certificate)
File "/home/user/.local/lib/python2.7/site-packages/urllib3/contrib/appengine.py", line 103, in init "URLFetch is not available in this environment.")
Can someone helps me? Thanks for your time!