{"id":6653,"library":"gcloud-aio-taskqueue","title":"Google Cloud Task Queue Client (Asyncio)","description":"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.","status":"active","version":"7.0.0","language":"python","source_language":"en","source_url":"https://github.com/talkiq/gcloud-aio","tags":["google-cloud","task-queue","asyncio","gcp","aiohttp","cloud-tasks"],"install":[{"cmd":"pip install gcloud-aio-taskqueue","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core HTTP client for asynchronous requests.","package":"aiohttp"},{"reason":"Provides shared authentication and session management utilities for gcloud-aio libraries.","package":"gcloud-aio-core"},{"reason":"Required for gRPC communication with Google Cloud APIs.","package":"grpcio"},{"reason":"Required for gRPC communication with Google Cloud APIs.","package":"grpcio-tools"},{"reason":"Used for serializing and deserializing data for gRPC.","package":"protobuf"}],"imports":[{"wrong":"from gcloud.aio.taskqueue import TaskQueueClient","symbol":"TaskQueueClient","correct":"from gcloud.aio.taskqueue import TaskQueueClient"}],"quickstart":{"code":"import asyncio\nimport os\nfrom gcloud_aio_taskqueue import TaskQueueClient\nfrom gcloud_aio_taskqueue.types import HttpMethod\nfrom gcloud_aio_core.session import Session\nfrom gcloud_aio_core.auth import build_credentials\n\nasync def main():\n    project_id = os.environ.get(\"GCP_PROJECT_ID\", \"your-project-id\")\n    queue_name = os.environ.get(\"GCP_TASK_QUEUE_NAME\", \"your-queue-name\")\n    \n    # Authenticate using GOOGLE_APPLICATION_CREDENTIALS env var or a service account path\n    # Example: GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json\n    credentials = build_credentials()\n\n    async with Session(credentials) as session:\n        client = TaskQueueClient(\n            project=project_id,\n            queue=queue_name,\n            session=session,\n        )\n\n        try:\n            # Add a task with required parameters (changes from v6.0.0 onwards)\n            task = await client.add_task(\n                url=\"https://example.com/mytaskendpoint\",\n                body=b\"Hello World!\",\n                payload_type=\"APPLICATION_OCTET_STREAM\",\n                method=HttpMethod.POST,\n                headers={\n                    \"Content-Type\": \"application/octet-stream\",\n                    \"X-Cloud-Task-ETA\": \"2025-01-01T00:00:00Z\" # Example custom header\n                }\n            )\n            print(f\"Task added: {task.name} (ID: {task.id})\")\n\n            # Example: Get a task\n            retrieved_task = await client.get_task(task.name)\n            print(f\"Retrieved task: {retrieved_task.name}\")\n\n            # Example: Delete a task\n            await client.delete_task(task.name)\n            print(f\"Task {task.name} deleted.\")\n\n        except Exception as e:\n            print(f\"An error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())","lang":"python","description":"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."},"warnings":[{"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`.","message":"The `add_task` method now returns a `Task` object instead of `None`.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Replace `payload=my_data` with `body=my_data`. Also, `payload_type` is now a mandatory parameter specifying the content type of the body.","message":"The `payload` parameter for `add_task` was removed and replaced with `body`.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Import `HttpMethod` from `gcloud_aio_taskqueue.types` and use it (e.g., `method=HttpMethod.POST`) instead of string literals (e.g., `method='POST'`).","message":"The `method` parameter for `add_task` now requires an `HttpMethod` enum member instead of a string.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Update your imports from `from gcloud_aio_taskqueue import Client` to `from gcloud_aio_taskqueue import TaskQueueClient`.","message":"The `Client` class was renamed to `TaskQueueClient` for better clarity and consistency.","severity":"breaking","affected_versions":">=7.0.0"},{"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.","message":"Always manage `gcloud_aio_core.session.Session` or `aiohttp.ClientSession` as an async context manager (`async with`).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'7.0.0':59 'aio':26,51 'aiohttp':68 'asynchron':8 'asyncio':6,30,66 'client':5,10 'cloud':2,15,35,62,70 'cloud-task':69 'compon':52 'current':56 'decoupl':46 'ecosystem':27 'gcloud':25,50 'gcloud-aio':24,49 'gcp':67 'googl':1,14,34,61 'google-cloud':60 'idiomat':29 'independ':39 'interact':12 'librari':19 'packag':42 'part':21 'provid':28 'python':9 'queue':4,17,65 'releas':44 'servic':36 'sub':41 'sub-packag':40 'support':31 'task':3,16,64,71 'task-queu':63 'various':33 'version':58","created_at":"2026-04-15T18:37:09.506439+00:00","updated_at":"2026-04-16T15:13:35.447297+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'TaskQueueClient' from 'gcloud.aio.taskqueue' (/tmp/tmpz3ihm2fv/venv/lib/python3.12/site-packages/gcloud/aio/taskqueue/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"7.0.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/talkiq/gcloud-aio","docs":null,"changelog":null,"pypi":"https://pypi.org/project/gcloud-aio-taskqueue/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["gcp","http-networking","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}