GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-docs-samples/tasks at master · shreyasgm/python-docs-samples

Expand file tree

/

tasks

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

tasks

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
README.md
README.md
 
 
pull_queue_snippets.py
pull_queue_snippets.py
 
 
pull_queue_snippets_test.py
pull_queue_snippets_test.py
 
 
requirements.txt
requirements.txt
 
 

README.md

Outline

Google Cloud Tasks Pull Queue Samples

Sample command-line program for interacting with the Google Cloud Tasks API using pull queues.

Pull queues let you add tasks to a queue, then programatically remove and interact with them. Tasks can be added or processed in any environment, such as on Google App Engine or Google Compute Engine.

pull_queue_snippets.py is a simple command-line program to demonstrate listing queues, creating tasks, and pulling and acknowledging tasks.

Prerequisites to run locally:

Please refer to Setting Up a Python Development Environment.

Authentication

To set up authentication, please refer to our authentication getting started guide.

Creating a queue

To create a queue using the Cloud SDK, use the following gcloud command:

gcloud alpha tasks queues create-pull-queue my-pull-queue

Running the Samples

Set the environment variables:

Set environment variables:

First, your project ID:

export PROJECT_ID=my-project-id

Then the queue ID, as specified at queue creation time. Queue IDs already created can be listed with gcloud alpha tasks queues list.

export QUEUE_ID=my-pull-queue

And finally the location ID, which can be discovered with gcloud alpha tasks queues describe $QUEUE_ID, with the location embedded in the "name" value (for instance, if the name is "projects/my-project/locations/us-central1/queues/my-pull-queue", then the location is "us-central1").

export LOCATION_ID=us-central1

Create a task for a queue:

python pull_queue_snippets.py create-task --project=$PROJECT_ID --queue=$QUEUE_ID --location=$LOCATION_ID

Pull and acknowledge a task:

python pull_queue_snippets.py pull-and-ack-task --project=$PROJECT_ID --queue=$QUEUE_ID --location=$LOCATION_ID

Note that usually, there would be a processing step in between pulling a task and acknowledging it.

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.