Skip to main content

Google Taskqueue client

Support for Python client for Task Queue Rest API using gcloud

Required Dependencies

The following third-party Python modules are required: - gcloud

The easiest way to install the dependencies is to run:

$ pip install -r requirements.txt

Why an interface to the Task Queue API?

The Google Cloud Client Library for Python (gcloud) is great, but it’s missing an interface to the Task Queue Rest API. This is understandable, because the API is experimental and still in alpha, and not fully accesble from outside the App Egine. And gcloud does support Pubsub.

However, Task Queues offer a few functions that aren’t available in Pubsub. And although Push Queues are restricted to use within App Engine, Pull Queues can be used outside the App Engine enviroment.

With Pull Queues a worker can lease tasks for a certain period. During this period, the tasks aren’t available to other workers. This prevents processing a single task multiple times by different workers. This makes Task Queues very useful for background processing, for example in combination with object change notifications, to process objects in a Storage Bucket the moment they are changed or created.

Example

Example:

>>> from gcloud_taskqueue import Taskqueue, Client

For object change notifications, you need to create a service account. To pull tasks created with this account, you need to use it’s credentials:

>>> json_credentials_path = "/path/to/my-service-credential.json"
>>> client = Client.from_service_account_json(json_credentials_path, project="my-project")

Get taskqueue:

>>> tq = Taskqueue(client=client, id="my-taskqueue")

Get tasks in taskqueue:

>>> for task in tq.list_tasks(client=client):
>>>     print("{}\t{}\t{}".format(task.id, task.leaseTimestamp, task.retry_count))

Lease 10 tasks for 60 seconds:

>>> for task in tq.lease(lease_time=60, num_tasks=10, client=client):
>>>     print("{}\t{}\t{}".format(task.id, task.leaseTimestamp, task.retry_count))

Lease 10 tasks with specific tag for 60 seconds:

>>> for task in tq.lease(lease_time=60, num_tasks=10, tag='my-tag', client=client):
>>>     print("{}\t{}\t{}".format(task.id, task.leaseTimestamp, task.retry_count))

Release files for gcloud_taskqueue 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gcloud_taskqueue 0.0.10
File Size Uploaded
gcloud_taskqueue-0.0.10.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gcloud_taskqueue 0.0.10
File Interpreter ABI Platform
gcloud_taskqueue-0.0.10-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 20.4 kB

Release files / gcloud_taskqueue-0.0.10.tar.gz

Download URL gcloud_taskqueue-0.0.10.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
deec22bb4bf80f8ff260fa7081115d5d5afb433c1232a847553ab9364ac3ebb5
BLAKE2b-256 checksum
How to use checksums
0eb4e011e3ba22373ec6254c113db8a64615f5c700656c40339f8caf99d05ed8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / gcloud_taskqueue-0.0.10-py2.py3-none-any.whl

Download URL gcloud_taskqueue-0.0.10-py2.py3-none-any.whl
Size 12.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
88beeeda9aec9745b4bd2c780502cc3cdfb155825d60aeb075ebc34dd0c330a1
BLAKE2b-256 checksum
How to use checksums
534d14e941841863ecf67813ee527f2965353b258d625766b63841da3832eda2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

This release

0.0.10 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

1 release file

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page