Registry / gcp / gcloud-aio-taskqueue

gcloud-aio-taskqueue

JSON →
library7.0.0pypypiunverified

An asynchronous Python client for interacting with Google Cloud Task Queue. This library is part of the `gcloud-aio` ecosystem, providing idiomatic `asyncio` support for various Google Cloud services. As an independent sub-package, its releases are decoupled from other `gcloud-aio` components, and it's currently at version 7.0.0.

pip install gcloud-aio-taskqueue
INSTALL
IMPORT
SIG · GCLOUD-AIO-TASKQUE
G
gcloud-aio-taskqueue
gcppythonv7.0.0
Install
5.7s avg
Import
—
Disk
61MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v7.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 60.1MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 5.7s · import 0.000s · 62MB
61MB installed
● package 61MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TaskQueueClient
✓ from gcloud.aio.taskqueue import TaskQueueClient
✗ from gcloud.aio.taskqueue import TaskQueueClient

This quickstart demonstrates how to initialize the `TaskQueueClient`, authenticate using environment variables or service account paths, and perform common operations like adding, retrieving, and deleting tasks. It highlights the use of `gcloud_aio_core.session.Session` for proper async context management and necessary parameters for `add_task` after recent breaking changes.

import asyncio import os from gcloud_aio_taskqueue import TaskQueueClient from gcloud_aio_taskqueue.types import HttpMethod from gcloud_aio_core.session import Session from gcloud_aio_core.auth import build_credentials async def main(): project_id = os.environ.get("GCP_PROJECT_ID", "your-project-id") queue_name = os.environ.get("GCP_TASK_QUEUE_NAME", "your-queue-name") # Authenticate using GOOGLE_APPLICATION_CREDENTIALS env var or a service account path # Example: GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json credentials = build_credentials() async with Session(credentials) as session: client = TaskQueueClient( project=project_id, queue=queue_name, session=session, ) try: # Add a task with required parameters (changes from v6.0.0 onwards) task = await client.add_task( url="https://example.com/mytaskendpoint", body=b"Hello World!", payload_type="APPLICATION_OCTET_STREAM", method=HttpMethod.POST, headers={ "Content-Type": "application/octet-stream", "X-Cloud-Task-ETA": "2025-01-01T00:00:00Z" # Example custom header } ) print(f"Task added: {task.name} (ID: {task.id})") # Example: Get a task retrieved_task = await client.get_task(task.name) print(f"Retrieved task: {retrieved_task.name}") # Example: Delete a task await client.delete_task(task.name) print(f"Task {task.name} deleted.") except Exception as e: print(f"An error occurred: {e}") if __name__ == "__main__": asyncio.run(main())
Debug
Known issues
breakingThe `add_task` method now returns a `Task` object instead of `None`.
fix
Update your code to expect and handle the returned `Task` object, accessing its `name` or `id` attributes directly. Previously, you would not get a direct return value from `add_task`.
affects: >=7.0.0
breakingThe `payload` parameter for `add_task` was removed and replaced with `body`.
fix
Replace `payload=my_data` with `body=my_data`. Also, `payload_type` is now a mandatory parameter specifying the content type of the body.
affects: >=6.0.0
breakingThe `method` parameter for `add_task` now requires an `HttpMethod` enum member instead of a string.
fix
Import `HttpMethod` from `gcloud_aio_taskqueue.types` and use it (e.g., `method=HttpMethod.POST`) instead of string literals (e.g., `method='POST'`).
affects: >=6.0.0
breakingThe `Client` class was renamed to `TaskQueueClient` for better clarity and consistency.
fix
Update your imports from `from gcloud_aio_taskqueue import Client` to `from gcloud_aio_taskqueue import TaskQueueClient`.
affects: >=7.0.0
gotchaAlways manage `gcloud_aio_core.session.Session` or `aiohttp.ClientSession` as an async context manager (`async with`).
fix
Ensure your client instantiation and usage is wrapped in an `async with Session(...) as session:` block to properly handle resource cleanup and avoid connection leaks.
affects: all
Upgrade
Version history
7.0.0latest on PyPI · released Sep 13, 2023
Audit
Dependencies
aiohttprequiredCore HTTP client for asynchronous requests.
gcloud-aio-corerequiredProvides shared authentication and session management utilities for gcloud-aio libraries.
grpciorequiredRequired for gRPC communication with Google Cloud APIs.
grpcio-toolsrequiredRequired for gRPC communication with Google Cloud APIs.
protobufrequiredUsed for serializing and deserializing data for gRPC.
Agent activity
34 hits · last 30 days
node
30
OpenAI (training)
1
Resources
gcloud-aio-taskqueue — pip install gcloud-aio-taskqueue · libregistry