Package: asyncnsq
asyncnsqasync nsq with asyncioif you dont like the pynsq(which use tornado) way to interact with nsq, then this library may be suitable for youyou can use this library as the common way to write thingsImportantfrom version 1.0.0 asyncnsq  has a break change in apiit is not stable yetyou may want to use stable " pip install asyncnsq==0.4.5"FeaturesHttp Clientsupport all the method nsq http suppliedTcp ClientConnectionlow level connection.Readerreader from both lookupd for auto finding nsqdlist of known nsqd but they can not use together.above two can't use togetherWriterall the common method for nsqd writerNext Featuresdifferent reader protocol supportmore doc to writemore testsInstallpip install asyncnsqUsage examplesAll you need is a loop, then enjoy. you can refer to examples, as well.Consumer:fromasyncnsqimportcreate_readerfromasyncnsq.utilsimportget_loggerloop=asyncio.get_event_loop()asyncdefgo():try:reader=awaitcreate_reader(nsqd_tcp_addresses=['127.0.0.1:4150'],max_in_flight=200)awaitreader.subscribe('test_async_nsq','nsq')asyncformessageinreader.messages():print(message.body)awaitmessage.fin()exceptExceptionastmp:self.logger.exception(tmp)loop.run_until_complete(go())Producer:fromasyncnsqimportcreate_writerloop=asyncio.get_event_loop()asyncdefgo():writer=awaitcreate_writer(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)foriinrange(100):awaitwriter.pub('test_async_nsq','test_async_nsq:{i}'.format(i=i))awaitwriter.dpub('test_async_nsq',i*1000,'test_delay_async_nsq:{i}'.format(i=i))loop.run_until_complete(go())RequirementsPython_ 3.6+https://www.python.orgnsq_http://nsq.iopython-snappyubuntu:sudo apt-get install libsnappy-devpip install python-snappycentos:sudo yum install snappy-develpip install python-snappymac:brew install snappy # snappy library from GoogleCPPFLAGS="-I/usr/local/include -L/usr/local/lib" pip install python-snappyRunning Testsinstall nsq requirementsinstall nsqhttps://nsq.io/deployment/installing.htmlinstall requirements (in a virtual environment)pip install aiohttp python-snappypip install pytestdev test package if you want autotest supportrun the auth server in a separate terminal sessionpython -m aiohttp.web -H localhost -P 8080 asyncnsq.http.auth:create_dev_auth_serverrun nsq in separate terminal sessionsif you've built nsq throughmake,cdinto thebuilddirectory of nsq./nsqlookupd./nsqd --lookupd-tcp-address=localhost:4160 -auth-http-address=localhost:8080run testspython runtests.pyexample output:$ python runtests.py test_reader_and_writer
decorator test_01_writer (tests.test_reader_and_writer.NsqTest) <_UnixSelectorEventLoop running=False closed=False debug=False> () {}
.decorator test_02_reader (tests.test_reader_and_writer.NsqTest) <_UnixSelectorEventLoop running=False closed=False debug=False> () {}
.
----------------------------------------------------------------------
Ran 2 tests in 0.260s

OKpytestjust pytest will do all the trick$ pytest -k test_reader_and_writer
------------------------------------------------------------------------------ live log call    -------------------------------------------------------------------------------
DEBUG    asyncnsq.tcp:connection.py:82 execute command b'IDENTIFY\n\x00\x00\x00\x1d {"feature_negotiation": true}'
DEBUG    asyncnsq.tcp:connection.py:239 got nsq data: (0, b'{"max_rdy_count":2500,"version":"1.2.0",    "max_msg_timeout":900000,"msg_timeout":60000,"tls_v1":false,"deflate":false,"deflate_level":6,  "max_deflate_level":6,"snappy":false,"sample_rate":0,"auth_required":false,"output_buffer_size":16384,    "output_buffer_timeout":250}')
DEBUG    asyncnsq.tcp:connection.py:208 Task is canceled
SKIPPED (no auth    enabled)                                                                                                                                              [ 75%]
tests/test_reader_and_writer.py::NsqTest::test_04_reader_fail_missing_secret
------------------------------------------------------------------------------ live log call    -------------------------------------------------------------------------------
DEBUG    asyncnsq.tcp:connection.py:82 execute command b'IDENTIFY\n\x00\x00\x00\x1d {"feature_negotiation": true}'
DEBUG    asyncnsq.tcp:connection.py:239 got nsq data: (0, b'{"max_rdy_count":2500,"version":"1.2.0",    "max_msg_timeout":900000,"msg_timeout":60000,"tls_v1":false,"deflate":false,"deflate_level":6,  "max_deflate_level":6,"snappy":false,"sample_rate":0,"auth_required":false,"output_buffer_size":16384,    "output_buffer_timeout":250}')
DEBUG    asyncnsq.tcp:connection.py:208 Task is canceled
SKIPPED (no auth    enabled)                                                                                                                                              [100%]

=============================================================== 2 passed, 2 skipped, 39 deselected in 0.    65s ================================================================LicenseThe asyncnsq is offered under MIT license.