App Engine development server fails to execute queued task - with no stack trace whatsoever
<p>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:</p>

<pre><code>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
</code></pre>

<p>Furthermore, it doesn't seem like the desired code is being executed.</p>

<p>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.</p>

<pre><code>#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 {}.&lt;br&gt;'.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()
</code></pre>

<p>app.yaml</p>

<pre><code># 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
</code></pre>

<p>queue.yaml</p>

<pre><code># queue.yaml

queue:
- name: my-queue
  rate: 1/s
  bucket_size: 40
  max_concurrent_requests: 1
</code></pre>

<p>I've found the answer here: <a href="https://stackoverflow.com/a/13552794">https://stackoverflow.com/a/13552794</a></p>

<p>Apparently, all I have to do is add the POST method to whichever handler is called for queuing.</p>

<p>So</p>

<pre><code>@app.route("/sample_task")
def sample_task():
...
</code></pre>

<p>should instead be:</p>

<pre><code>@app.route("/sample_task", methods=['POST'])
def sample_task():
...
</code></pre>

python google-app-engine flask google-app-engine-python