Skip to content

Instantly share code, notes, and snippets.

@misja
Created May 23, 2016 08:59
Show Gist options
  • Save misja/8c0fcc27a7ce5633453e14e4e0e5b840 to your computer and use it in GitHub Desktop.
Save misja/8c0fcc27a7ce5633453e14e4e0e5b840 to your computer and use it in GitHub Desktop.
import nsq
import time
import asyncio
import tornado
import tornado.ioloop
import tornado.platform.asyncio
def pub_callback(conn, data):
print(data)
async def go():
writer = nsq.Writer(('127.0.0.1:4150'))
for i in range(10):
await asyncio.sleep(.1)
writer.pub('test', time.strftime('%H:%M:%S').encode(), pub_callback)
if __name__ == '__main__':
tornado.platform.asyncio.AsyncIOMainLoop().install()
loop = asyncio.get_event_loop()
loop.run_until_complete(go())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment