summaryrefslogtreecommitdiff
path: root/t.py
diff options
context:
space:
mode:
Diffstat (limited to 't.py')
-rw-r--r--t.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/t.py b/t.py
new file mode 100644
index 00000000..8bb58db3
--- /dev/null
+++ b/t.py
@@ -0,0 +1,43 @@
+import nsq
+import time
+import logging
+from nsq.async import AsyncConn
+from kombu.async.tornado import TornadoHub
+from kombu.five import monotonic
+from kombu.log import setup_logging
+
+setup_logging(loglevel=logging.INFO)
+
+hub = TornadoHub()
+
+count = 0
+finished = 0
+N = 10000
+
+writer = nsq.Writer(['localhost:4150'], io_loop=hub)
+
+def pub_message(i):
+ writer.pub('cstress', str(i) , finish_pub)
+
+def finish_pub(conn, data):
+ global finished
+ finished += 1
+ if finished >= N:
+ print('TIME: %r' % (monotonic() - time_start,))
+
+
+def on_it():
+ global count
+ global time_start
+ if count == 0:
+ time_start = monotonic()
+ if count > N + 1:
+ return
+ count += 1
+ pub_message(count)
+ hub.call_soon(on_it)
+
+hub.call_later(1, on_it)
+#hub.call_repeatedly(1, pub_message)
+hub.run_forever()
+