I am using the flask application on the google app engine flexible
environment.
1. I want to create a task whenever some URL has been hit by a user and
queues should hit the google app engine endpoint for executing the task.
For example, I am appending the code here
The same code is working fine and creating a task if executed from another
server
import json
import datetime
from google.cloud import tasks_v2beta3
from google.protobuf import timestamp_pb2
import json
import datetime
from google.cloud import tasks_v2beta3
from google.protobuf import timestamp_pb2
class CloudTaskManager:
def __init__(self):
self.client = tasks_v2beta3.CloudTasksClient()
def create_task(self, project, queue, location, payload=None,
in_seconds=5):
parent = self.client.queue_path(project, location, queue)
task = {
'app_engine_http_request': {
'http_method': tasks_v2beta3.HttpMethod.POST,
'relative_uri': '/api/v1/rating/cloud_task_handler',
'headers': {
'Content-Type': 'application/json',
'Org_Name': 'organization1'
},
'body': json.dumps(payload).encode()
}
}
if in_seconds is not None:
d = datetime.datetime.utcnow() +
datetime.timedelta(seconds=in_seconds)
timestamp = timestamp_pb2.Timestamp()
timestamp.FromDatetime(d)
task['schedule_time'] = timestamp
response = self.client.create_task(parent=parent, task=task)
return response
2. Another case is that I want to use cloud firestore API that is in native
mode and the code snippet are as below.
cred = credentials.Certificate('name.json')
# cred = credentials.ApplicationDefault()
if not firebase_admin._apps:
firebase_admin.initialize_app(cred, {
'projectId': 'project-id',
})
db = firestore.client()
collection_refs = db.collection('collection-name')
documents = collection_refs.stream()
for doc in documents:
return doc.to_dict()
On Thu, Mar 18, 2021 at 1:45 AM 'jlibera' via Google App Engine <
[email protected]> wrote:
> Hi,
>
> Would you be able to please provide a screenshot or full log the error
> message/response you are seeing? This will help to better visualize and
> diagnose as to why these are occurring in the first place. Better yet, I
> would suggest to open an public issue tracker ticket [1] to look into your
> inquiry further.
>
> Would you be able to provide a little more details regarding your
> implementation as well as application architecture? This will help to
> better visualize how these components are integrated, as well as provide
> possible alternatives for the bottlenecks that your app is experiencing.
>
> [1] issuetracker.google.com
>
> On Wednesday, March 17, 2021 at 9:42:51 AM UTC-4 [email protected]
> wrote:
>
>> When calling the cloud task and cloud firestore API from app engine
>> flexible environment running flask application, I am getting no
>> error/response for a long time and it gets timed out.
>>
>> But same API call is working fine from another server outside of google
>> cloud using the same service account.
>>
>> Can you please help me if the above two API can be called from the app
>> engine flexible environment or if some settings need to be changed?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-appengine/0657990c-5d35-4d59-9fdc-ebfa09c5863bn%40googlegroups.com
> <https://groups.google.com/d/msgid/google-appengine/0657990c-5d35-4d59-9fdc-ebfa09c5863bn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/CANtQv3dR1v-y5CNuKk7xwsjcvM6FxdcOnjnRGFfUnUXJABm1sA%40mail.gmail.com.