分享

用pykakfa发数据,一段时间后突然自动退出,怎么回事?

grinsky 发表于 2017-4-12 16:26:37 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 3 11301
用Python写了个脚本,通告pykafka把数据不停的往kafka里发送,但执行一段时间后就自动退出了,也没有报错。日志部分如下:
2017-04-12 16:20:00,506  DEBUG   403  Sending 1 messages to broker 76
2017-04-12 16:20:00,569  DEBUG   464  Successfully sent 1/1 messages to broker 76
2017-04-12 16:20:16,956  DEBUG   190  Finalising <pykafka.producer.Producer at 0x314c5f8L>
2017-04-12 16:20:16,956  INFO   489  Blocking until all messages are sent
2017-04-12 16:20:20,605  INFO   547  Worker exited for broker atomtree003:9092
2017-04-12 16:20:20,605  INFO   489  Blocking until all messages are sent
2017-04-12 16:20:20,605  INFO   184  RequestHandler.stop: about to flush requests queue
2017-04-12 16:20:20,605  INFO   184  RequestHandler.stop: about to flush requests queue
2017-04-12 16:20:20,605  INFO   184  RequestHandler.stop: about to flush requests queue
字面意思好像是刷新队列,但怎么就退出了呢?

已有(3)人评论

跳转到指定楼层
arsenduan 发表于 2017-4-12 17:52:44
2017-04-12 16:20:00,506  DEBUG   403  Sending 1 messages to broker 76
2017-04-12 16:20:00,569  DEBUG   464  Successfully sent 1/1 messages to broker 76
2017-04-12 16:20:16,956  DEBUG   190  Finalising <pykafka.producer.Producer at 0x314c5f8L>
2017-04-12 16:20:16,956  INFO   489  Blocking until all messages are sent
2017-04-12 16:20:20,605  INFO   547  Worker exited for broker atomtree003:9092
2017-04-12 16:20:20,605  INFO   489  Blocking until all messages are sent
2017-04-12 16:20:20,605  INFO   184  RequestHandler.stop: about to flush requests queue
2017-04-12 16:20:20,605  INFO   184  RequestHandler.stop: about to flush requests queue
2017-04-12 16:20:20,605  INFO   184  RequestHandler.stop: about to flush requests queue
不知道楼主程序怎么写的。这个应该是正常退出。
上面是发送消息到 broker 76
发送成功
成功之后,worker退出
停止,然后接着刷新请求队列.

下面代码

[mw_shl_code=python,true]def stop(self):
"""Stop the request processor."""
shared = self.shared
self.shared = None
log.info("RequestHandler.stop: about to flush requests queue")
shared.requests.join()
shared.ending.set()[/mw_shl_code]
来自下面附件
python.rar (1.96 KB, 下载次数: 0)
回复

使用道具 举报

grinsky 发表于 2017-4-13 10:38:08
arsenduan 发表于 2017-4-12 17:52
不知道楼主程序怎么写的。这个应该是正常退出。
上面是发送消息到 broker 76
发送成功

按照你的思路,我去看了下,找到了这个
    def __del__(self):
        if log:  # in case log is finalized before self
            log.debug("Finalising {}".format(self))
        self.stop()


这个是说我日志设置出问题了吗?
回复

使用道具 举报

2017 发表于 2017-4-13 15:47:46
grinsky 发表于 2017-4-13 10:38
按照你的思路,我去看了下,找到了这个
    def __del__(self):
        if log:  # in case log is fi ...

代码贴出来看下。
既然有停止的条件,那停止应该是正常的

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条