Skip to main content

asyncio async/await nsq support

Project description

asyncnsq (work in progress,仍然开发中)
=========================
asyncnsq with python3.6 await/async supported

Latest Updates
--------------

support dpub

Usage examples
--------------

All you need is a loop, then enjoy

Consumer:

loop = asyncio.get_event_loop()

async def go():
nsq_consumer = await create_nsq_consumer(host='tcp://127.0.0.1:4150',
max_in_flight=200)
await nsq_consumer.subscribe('test_async_nsq', 'nsq')
for waiter in nsq_consumer.wait_messages():
message = await waiter
print(message.body)
await message.fin()

loop.run_until_complete(go())

Producer:

loop = asyncio.get_event_loop()

async def go():
nsq_producer = await create_nsq_producer(host='127.0.0.1', port=4150,
heartbeat_interval=30000,
feature_negotiation=True,
tls_v1=True,
snappy=False,
deflate=False,
deflate_level=0,
loop=loop)
for i in range(10):
await nsq_producer.pub('test_async_nsq', 'test_async_nsq:{i}'.format(i=i))
await nsq_producer.dpub('test_async_nsq', i * 1000,
'test_delay_async_nsq:{i}'.format(i=i))
loop.run_until_complete(go())

you can use host like 'tcp://127.0.0.1:4150' or '127.0.0.1' with port=4150

As for now, only single nsqd addr supported.

Requirements
------------

* Python_ 3.5+ https://www.python.org
* nsq_ http://nsq.io

* python-snappy
1. ubuntu:
- sudo apt-get install libsnappy-dev
- pip install python-snappy
2. centos:
- sudo yum install snappy-devel
- pip install python-snappy
3. mac:
- brew install snappy # snappy library from Google
- CPPFLAGS="-I/usr/local/include -L/usr/local/lib" pip install python-snappy

License
-------

The asyncnsq is offered under MIT license.

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

asyncnsq-0.3.0.tar.gz (14.4 kB view details)

Uploaded Source

File details

Details for the file asyncnsq-0.3.0.tar.gz.

File metadata

  • Download URL: asyncnsq-0.3.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for asyncnsq-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d510509ab58f4ed27d6fa5296b7fd29d3bb95aa72add6a96ec8dbb30232af75f
MD5 71df7550222628d85310adaed3ff579e
BLAKE2b-256 1fe87a3536836389a73b467f8457442221a3d1ab6d52defff07bfca0e3150370

See more details on using hashes here.

Supported by

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