I am trying to schedule a task to run in background. I can't seem to find
a example.
I posted this on Stackoverflow and I received one response:
I've not really done much with Cloud Endpoints in python, but 415 is
*Unsupported
Media Type*. Since you are posting to an endpoint, it's probably expecting
a Content-type of application/json and a payload like {"key": "key"}
But I am not making a call, I am using the taskqueue function, which is
making the call and it should know how to make the http call.
Anyone have an example or an idea on how to make this work?
0down votefavorite
<http://stackoverflow.com/questions/35559644/how-to-create-a-task-in-gae-using-python?noredirect=1#>
I will be the first to admit that I have no idea how to make this work, but
I can't seem to find any examples.
What I am trying to do is to execute a Task in Background on the GAE using
python.
I have a function that I am calling from the client that is taking longer
than 1 minute and is timing out. So, my solution is to make it a background
task. It could also be a cron task.
Where I am running into issues is in trying to configure a url that I can
pass to the taskqueue.add function
@endpoints.method(endpoints.ResourceContainer(SimpleMessage), SimpleMessage,
path='rdflib_add_task', http_method='POST', name='rdflib.add_task')
def RdfLibAddTask(self, request):
# Add the task to the default queue.
taskqueue.add(url='/_ah/spi/TTApi.RdfLibTaskTest', params={'key': "key"})
return SimpleMessage(message="response")
@endpoints.method(endpoints.ResourceContainer(SimpleMessage), SimpleMessage,
path='rdflib_task_test', http_method='POST', name='rdflib.task_test')
def RdfLibTaskTest(self, params):
print "in RdfLibTaskTest", params
return SimpleMessage(message="RdfLibTaskTest")
When I call the "RdfLibAddTask" from the client it works and adds the task
to my default queue. However, the default queue runs the task a bunch of
times and they all fail with a 415.
0.1.0.2 - - [22/Feb/2016:08:50:23 -0800] "POST /_ah/spi/TTApi.RdfLibTaskTest
HTTP/1.1" 415 574 https://ttapi-test-ms.appspot.com/_ah/spi/TTApi.RdfLibAddTask
"AppEngine-Google; (+http://code.google.com/appengine)"
"ttapi-test-ms.appspot.com" ms=26 cpu_ms=14 cpm_usd=6.4149e-8
instance=00c61b117c7a727c0cabea61b0086576f7ca4fe4 app_engine_release=1.9.33
trace_id=-
So, I am doing something wrong and I can't find a simple example that will
let me proceed. Can anyone identify what is wrong with my example or
provide me with a working example? And it doesn't have to be a push queue,
it could be a cron task.
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/74ea5fe9-021a-4a4c-95c5-1e8dff1ef419%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.