【问题标题】:pynsq: Reader object has no attribute 'finish'pynsq:阅读器对象没有属性“完成”
【发布时间】:2013-07-30 16:05:37
【问题描述】:

这个错误发生在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

【问题讨论】:

    标签: python nsq pynsq


    【解决方案1】:

    此问题已在 pynsq 的最新版本 0.5.0 中修复

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多