title: Google Cloud Tasks & Google App Engine Python 3
body: <p>I am trying to work with the <a href="https://cloud.google.com/tasks/docs/" rel="nofollow noreferrer">Google Cloud Tasks API</a></p>
  
  <p>In python2.7 app engine standard you had this amazing library (<a href="https://cloud.google.com/appengine/articles/deferred" rel="nofollow noreferrer">deferred</a>) that allowed you to easily assign workers to multiple tasks that could be completed asynchronisly. </p>
  
  <p>So in a webapp2 handler I could do this:</p>
  
  <pre><code>create_csv_file(data):
    #do a bunch of work ...
    return
  
  MyHandler(webapp2.Handler):
    def get(self)
      data = myDB.query()
      deferred.defer(create_csv_file, data)
  </code></pre>
  
  <p>Now I am working on the new Google App Engine Python 3 runtime and the deferred library is not available for GAE Py3.</p>
  
  <p>Is the google cloud tasks the correct solution/replacement?</p>
  
  <p>This is where I am at now... I've scoured the internet looking for answer but my Google powers have failed me. I've found come examples but they are not very good and they appear as though you should be creating creating /adding tasks from gcloud console or locally but no examples of adding tasks from a front end api endpoint.  </p>
  
  <pre><code>ExportCSVFileHandler(Resource):
    def get(self):
      create_task()
      return 
  
  CSVTaskHandler(Resource):
    def(post):
      #do a lot of work creating a csv file
      return
  
  create_task():
      client = tasks.CloudTasksClient(credentials='mycreds')
      project = 'my-project_id'
      location = 'us-east4'
      queue_name = 'csv-worker'
  
      parent = client.location_path(project, location)
  
      the_queue = {
          'name': client.queue_path(project, location, queue_name),
          'rate_limits': {
              'max_dispatches_per_second': 1
          },
          'app_engine_routing_override': {
              'version': 'v2',
              'service': 'task-module'
          }
      }
  
      queues = [the_queue]
      task = {
          'app_engine_http_request': {
              'http_method': 'GET',
              'relative_uri': '/create-csv',
              'app_engine_routing': {
                  'service': 'worker'
              },
              'body': str(20).encode()
          }
      }
  
      # Use the client to build and send the task.
      response = client.create_task(parent, task)
  
      print('Created task {}'.format(response.name))
  
      # [END taskqueues_using_yaml]
      return response
  </code></pre>