diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2013-03-10 13:48:35 +0200 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2013-03-10 13:48:35 +0200 |
| commit | 27a1f8b8755aadcf63906005f297ff8b9b0678f9 (patch) | |
| tree | fae18f5ed4961b2182c1c36cdc17882db3105d40 /bitrade.py | |
| parent | 6b2e0794d3e1786370368ade88b042f96bb0607a (diff) | |
Send entire order messages
Diffstat (limited to 'bitrade.py')
| -rw-r--r-- | bitrade.py | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1,4 +1,5 @@ # encoding: utf8 +import logging import os import tornado.httpserver @@ -8,6 +9,8 @@ import tornado.ioloop import tornado.gen import tornadoredis +from time import time +from uuid import uuid4 c = tornadoredis.Client() c.connect() @@ -30,8 +33,15 @@ class OrderHandler(tornado.websocket.WebSocketHandler): yield tornado.gen.Task(self.client.subscribe, 'test_channel') self.client.listen(self.on_order) + @tornado.gen.engine def on_message(self, msg): - c.publish('test_channel', msg) + order_time = time() + order_id = uuid4().hex + order = '{}|{}'.format(order_id, msg) + with c.pipeline() as pipe: + pipe.zadd('order_log', order_time, order) + pipe.publish('test_channel', order) + yield tornado.gen.Task(pipe.execute) def on_order(self, msg): if msg.kind == 'message': |
