pynsq处理长时间任务

新手上路,请多包涵

在我使用pynsq的时候遇到这样的问题,需要处理长时间的任务,nsq报错提示:

ERROR:nsq.client:[127.0.0.1:4150:hello:channel] 
ERROR: ConnectionClosedError('Stream is closed',)
WARNING:nsq.reader:[127.0.0.1:4150:hello:channel] connection closed

这是我的测试代码:

def process_message(message):
    print(message)
    time.sleep(100)
    message.touch()
    return True


r_check = nsq.Reader(
    message_handler=process_message,
    nsqd_tcp_addresses=['127.0.0.1:4150'],
    topic='hello', channel='channel',
    lookupd_poll_interval=15,
    lookupd_connect_timeout=100000,
    lookupd_request_timeout=100000,
    max_tries=10
)

nsq.run()  # tornado.ioloop.IOLoop.instance().start()
阅读 5.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进