-
Notifications
You must be signed in to change notification settings - Fork 13
Documentation on scheduling a app_engine_http_request seems incorrect #62
Comments
I just tried the same thing using python3.8 and google-cloud-tasks 2.0.0 (using the code example from the documentation), and obtained the same error. |
It would seem that this is an issue of documentation, rather than an issue of the API in it-self. """Create a task for a given queue with an arbitrary payload."""
from google.cloud import tasks_v2
from time import time
from google.cloud.tasks_v2.proto.target_pb2 import HttpMethod
# Create a client.
client = tasks_v2.CloudTasksClient()
# TODO(developer): Uncomment these lines and replace with your values.
# project = 'my-project-id'
# queue = 'my-appengine-queue'
# location = 'us-central1'
# payload = 'hello'
# Construct the fully qualified queue name.
parent = client.queue_path(project, location, queue)
# Construct the request body.
task = {
'app_engine_http_request': { # Specify the type of request.
'http_method': HttpMethod.POST,
'relative_uri': '/example_task_handler'
}
}
if payload is not None:
# The API expects a payload of type bytes.
converted_payload = payload.encode()
# Add the payload to the request.
task['app_engine_http_request']['body'] = converted_payload
if in_seconds is not None:
# Time of requested execution, in seconds
seconds = seconds=int(time() + in_seconds)
# Add the timestamp to the tasks.
task['schedule_time'] = tasks_v2.types.Timestamp(seconds=seconds)
# Use the client to build and send the task.
response = client.create_task(parent=parent, task=task)
print('Created task {}'.format(response.name))
return response |
schedule_time
Please update to the newest library version for the sample to work as is: 2.1.0 |
Please re-open if you are still experiencing this issue. |
Hi, I am seeing this issue in version 2.3.0 I am running the below
I get |
Hi @pduggi-cf , please see the sample for converting datetime to Timestamp: python-tasks/samples/snippets/create_http_task.py Lines 68 to 72 in 2243d84
|
The documentation at https://cloud.google.com/tasks/docs/creating-appengine-tasks seems to be the problem Thanks for pointing me in the right direction |
Hi,
I'm having an issue creating scheduled Cloud Tasks, using python 2. 7 : they won't work throwing a TypeError.
It's probably worth noting that as long as I dont use the
in_seconds
every thing work as expected.Am I missing something ?
Thanks
Environment details
google-cloud-tasks
version: 1.5.0Steps to reproduce
app_engine_http_request
in_seconds
Code example
-> https://cloud.google.com/tasks/docs/samples/cloud-tasks-appengine-create-task
I also tried different combinations for 'schedule_time' :
Nothing worked.
Stack trace
The text was updated successfully, but these errors were encountered: