Skip to main content

Asyncio Python Client for Google Cloud Pub/Sub

Project description

Latest PyPI Version Python Version Support

Installation

$ pip install --upgrade gcloud-aio-pubsub

Usage

This Pub/Sub implementation is a slim wrapper around google-cloud-pubsub==0.25.0 with a few key features:

  • intermittent gRPC communication errors are (optionally) captured

  • an optionally infinite async subscription poller has been introduced

The upstream pubsub implementation has been pinned to 0.25 since newer versions can cause odd errors when combined with asyncio processing. At the time of this writing, a new version of the upstream pubsub implementation is being generated – once we’ve tested that version, will update this library.

Here’s the rough usage pattern for subscribing:

import gcloud.aio.pubsub as pubsub

subscriber = pubsub.Client(project)
topic = subscriber.topic(topic)
subscription = topic.subscription(subscription)

async for job_id, message in subscription.poll():
    # do something with message
    await subscription.acknowledge([job_id])

A couple additional features you might want to play with:

# creates a subscription/topic if it does not exist
subscription.create_if_missing()
topic.create_if_missing()

# the retries argument can be used to retry acks when intermittent gRPC
# errors are received
await subscription.acknowledge([job_ids], retries=3)

# the max_intermittent_errors argument can be used to retry pulls when
# intermittent gRPC errors are received
# setting max_intermittent_errors=None allows any number of these errors
async for job_id, message in subscription.poll(max_intermittent_errors=3):
    ...

# similarly, the max_errors argument can be used to retry pulls when
# any non-intermittent error is generated by the pull command
# setting max_errors=None allows any number of these errors
async for job_id, message in subscription.poll(max_errors=3):
    ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcloud-aio-pubsub-0.5.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

gcloud_aio_pubsub-0.5.1-py2.py3-none-any.whl (9.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file gcloud-aio-pubsub-0.5.1.tar.gz.

File metadata

File hashes

Hashes for gcloud-aio-pubsub-0.5.1.tar.gz
Algorithm Hash digest
SHA256 b80776bba1d75a6b34740c756ce8a5e392c4d074fb8af88e58290add43e86e77
MD5 51cd71d87da12ac1c8c5cebcc60f7e4f
BLAKE2b-256 4da5d65b3e3a28ba85895c29e0dc14981dd8513d80f2f91c353a4b13c7f179be

See more details on using hashes here.

File details

Details for the file gcloud_aio_pubsub-0.5.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for gcloud_aio_pubsub-0.5.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fa344c40a13c38e08139299517974e9b5b6b0c8b574461e5eb9a7f461fcc5887
MD5 c380bfad2fbc352854f86104df64b55f
BLAKE2b-256 e098d12eaadad5fac2f1871e18d30e7c17f881ab254f9752f17f14e638ee1136

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page