Created
May 23, 2016 08:59
-
-
Save misja/8c0fcc27a7ce5633453e14e4e0e5b840 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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