Skip to main content

Blocking subscribe implementation of pyredis is annoying for some case. It is controllable with some technique, but here is a quick approach using a python thread.

Note: This implementation is good only for few situation.

Example

>>> import redis
>>> redisc = redis.Redis()
>>> import redispubsub
>>> pubsub = redispubsub.RedisPubsub(redisc.pubsub())
>>> pubsub.subscribe('1') # You SHOULD subscribe before starting thread.
>>> pubsub.start() # Start the router
>>> pubsub.dequeue('1')
{'pattern': None, 'type': 'subscribe', 'channel': '1', 'data': 1L}
>>> redisc.publish('1', 'test')
>>> pubsub.dequeue('1') # None returned
>>> pubsub.dequeue('1')
{'pattern': None, 'type': 'message', 'channel': '1', 'data': 'test'}
>>> pubsub.dequeue('1') # None returned

Download files

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

Source Distribution

redis-pubsub-helper-0.1.tar.gz (1.9 kB view details)

Uploaded Source

File details

Details for the file redis-pubsub-helper-0.1.tar.gz.

File metadata

File hashes

Hashes for redis-pubsub-helper-0.1.tar.gz
Algorithm Hash digest
SHA256 9c359ce0ad46285cd088fa103dbba1efb23097ddac72d5120d6f289db27b4d32
MD5 79e4a5c8af3c101853f6a84fe1fb93da
BLAKE2b-256 ed4154741b950c7aa5dff5545f6ff174d4f82b927c77c109b9f6e96abefe5220

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

1 file

This release

0.1 This release

1 file

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