示例#1
0
 def setUp(self):
     self._test_payload_01 = dict(a=u'öäü', b=14, c=['a', 'b'])
     self._test_payload_02 = dict(a=1.001, b=('a', 'b'), d=datetime.utcnow())
     d = self._test_payload_03 = dict(a=None, b=('a', 'b'))
     d['c'] = self._test_payload_01
     self._test_header_01 = dict(id=uuid.uuid4(), ts=timestamp_micro())
     return
示例#2
0
文件: dpub.py 项目: guidog/pywork
 def print_stat(self):
     if self.t_last is None or self.cnt == 0:
         return
     now = timestamp_micro()
     td = now - self.t_last
     cnt = self.cnt
     print "count: %d" % cnt
     print "time : %d µs" % td
     rs = float(cnt) / (float(td) / 1000000)
     print "r/s   : %.3f" % rs
     if cnt:
         tr = float(td) / float(cnt)
         print "µs/r  : %.3f" % tr
     print
     self.cnt = 0
     self.t_last = timestamp_micro()
     return
示例#3
0
 def setUp(self):
     self._test_payload_01 = dict(a=u'öäü', b=14, c=['a', 'b'])
     self._test_header_01 = dict(id=uuid.uuid4(),
                                 sender='me',
                                 parent=uuid.uuid4(),
                                 ts=timestamp_micro(),
                                 )
     return
示例#4
0
文件: dsub.py 项目: guidog/pywork
 def handle_receive(self, channel, message):
     now = timestamp_micro()
     if self.t_last is None:
         self.t_last = now
     self.cnt += 1
     pseq = message.payload[b'seq']
     if self.seq != pseq:
         print "  seq: %d <-> %d" % (self.seq, pseq)
         self.seq = pseq + 1
     else:
         self.seq += 1
     return
示例#5
0
 def timestamp(self):
     ts = self._header.setdefault(b'ts', timestamp_micro())
     return ts
示例#6
0
文件: dpub.py 项目: guidog/pywork
    def handle_send(self, channel, message):
        now = timestamp_micro()
##         print 'sent: ', message.id, '  t:', (now - message.timestamp)
##         self._outstanding.add(message)
        return
示例#7
0
文件: dpub.py 项目: guidog/pywork
 def handle_receive(self, channel, message):
     now = timestamp_micro()
     if self.t_last is None:
         self.t_last = now
     self.cnt += 1
     return
示例#8
0
 def setUp(self):
     p = dict(a=u'öäü', b=14, c=['a', 'b'], x={'a':(1,2), u'öäü':'X'})
     h = dict(id=uuid.uuid4(), sender='memyselfandI', topic=u'töäü', ts=timestamp_micro())
     self._msg = simplemsg.TopicMessage(header=h, payload=p)
     return