def on_error(self, headers, message): StatsListener.on_error(self, headers, message) self.error_list.append((headers, message)) self.error_condition.acquire() self.error_received = True self.error_condition.notify() self.error_condition.release()
def on_message(self, headers, message): StatsListener.on_message(self, headers, message) self.message_list.append((headers, message)) self.message_condition.acquire() self.message_received = True self.message_condition.notify() self.message_condition.release()
def __init__(self, receipt=None): StatsListener.__init__(self) WaitingListener.__init__(self, receipt) self.message_list = [] self.message_condition = threading.Condition() self.message_received = False self.error_list = [] self.error_condition = threading.Condition() self.error_received = False
def stats(self, args): ''' Usage: stats [on|off] Description: Record statistics on messages sent, received, errors, etc. If no argument (on|off) is specified, dump the current statistics. ''' if len(args) < 2: stats = self.c.get_listener('stats') if stats: print stats else: print 'No stats available' elif args[1] == 'on': self.c.set_listener('stats', StatsListener()) elif args[1] == 'off': self.c.remove_listener('stats') else: print 'expecting: stats [on|off]'
def __init__(self, receipt=None): StatsListener.__init__(self) WaitingListener.__init__(self, receipt) self.message_list = [] self.message_condition = threading.Condition() self.message_received = False
def __init__(self, receipt, subscribe_id, persister): StatsListener.__init__(self) WaitingListener.__init__(self, "%s%s" % (receipt, subscribe_id)) self.dbPersisted = persister self.id = subscribe_id