0

此错误发生在pynsq 0.4.2

堆栈跟踪


2013-07-30 15:03:43,205 ERROR [ip-10-114-195-89:4150:nsq_msg_handler] failed to handle_message() 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/nsq/Reader.py", line 367, in _data_callback
    self._handle_message(conn, message)
  File "/usr/local/lib/python2.7/dist-packages/nsq/Reader.py", line 291, in _handle_message
    return message.requeue()
  File "/usr/local/lib/python2.7/dist-packages/nsq/nsq.py", line 47, in requeue
    self.respond(REQ, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/nsq/Reader.py", line 211, in _message_responder
    self._requeue(conn, message, time_ms=kwargs.get('time_ms', -1))
  File "/usr/local/lib/python2.7/dist-packages/nsq/Reader.py", line 222, in _requeue
    return self.finish(conn, message)
AttributeError: 'Reader' object has no attribute 'finish'

代码



    def connect_nsq(self):
        r = nsq.Reader(message_handler=self.nsq_msg_handler, lookupd_http_addresses=["127.0.0.1:4161"], topic="test_topic", channel="test_channel", max_in_flight=500)

        nsq.run()


    # callback
    def nsq_msg_handler(self, message):
        try:
            before_ts = get_utc_now_ts() 
            json_data = json.loads(message.body)

            my_data = json_data["key1"]
            my_data = json_data["key2"]
            my_data = json_data["key3"]

            after_ts = get_utc_now_ts() 
            delta = after_ts - before_ts 
            logger.debug("took %f seconds for json_data _id: %s" % (delta, json_data["_id"])) 
        except Exception as reason:
            print reason, traceback.format_exc()
            return False

       return true

4

1 回答 1

0

此问题已在最新版本pynsq0.5.0中修复

这是错误报告:https ://github.com/bitly/pynsq/issues/44

于 2013-07-31T02:31:34.563 回答