mercredi 5 octobre 2016

App Engine development server fails to execute task and with no stack trace whatsoever

Vote count: 0

I'm currently trying to queue tasks in App Engine using the Flask framework, but I'm having some difficulty. I run my code, and it seems like the tasks are queued properly when I check the admin server at localhost:8000/taskqueue. However, the console repeatedly print the following error:

`
WARNING  2016-10-05 17:08:09,560 taskqueue_stub.py:1981] Task task1 failed to execute. This task will retry in 0.100 seconds
`

Furthermore, it doesn't seem like the desired code is being executed.

My question is, why isn't my code working? I apologize for the very broad question, however there's no stack trace to guide me through to something more specific. I've simplified my code however to make my error reproducible. The code below should print the phrase "sample task" onto the console 5 times. However, this does not occur.

`
#main.py

from google.appengine.api.taskqueue import taskqueue
from flask import Flask, Response

app = Flask(__name__)

@app.route("/get")
def get():
    for i in range(5):
        # attempt to execute the desired function 5 times
        # the message "sample task" should be printed to the console five times
        task = taskqueue.add(
            queue_name='my-queue',
            url='/sample_task',
        )
        message += 'Task {} enqueued, ETA {}.<br>'.format(task.name, task.eta)

    response = Response(message)
    return response

@app.route("/sample_task")
def sample_task():
    message = "sample task"
    print (message)
    return Response(message)


if __name__ == "__main__":
    app.run()
`

app.yaml

`
# app.yaml

runtime: python27
api_version: 1
threadsafe: true

# [START handlers]
handlers:
- url: /sample_task
  script: main.app
  login: admin

- url: /get
  script: main.app
  login: admin
`

queue.yaml

`
# queue.yaml

queue:
- name: my-queue
  rate: 1/s
  bucket_size: 40
  max_concurrent_requests: 1
`

asked 10 secs ago

Let's block ads! (Why?)



App Engine development server fails to execute task and with no stack trace whatsoever

Aucun commentaire:

Enregistrer un commentaire