当前位置: 首页>>代码示例>>Python>>正文


Python KafkaConsumer.commit_async方法代码示例

本文整理汇总了Python中kafka.KafkaConsumer.commit_async方法的典型用法代码示例。如果您正苦于以下问题:Python KafkaConsumer.commit_async方法的具体用法?Python KafkaConsumer.commit_async怎么用?Python KafkaConsumer.commit_async使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kafka.KafkaConsumer的用法示例。


在下文中一共展示了KafkaConsumer.commit_async方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: is_jpg

# 需要导入模块: from kafka import KafkaConsumer [as 别名]
# 或者: from kafka.KafkaConsumer import commit_async [as 别名]
        # make sure image is jpeg
        if is_jpg(image_data) == False:
            print("Invalid panda {0}".format(msg.offset))
            continue

        # run tensorflow image recognition
        predictions, top_k = run_inference_on_image(image_data)

        # determine if there is a panda match, if so how good the match is (score should be > 0.5)
        for node_id in top_k:
            # giant panda = 169
            # red panda = 7
            # human_string = node_lookup.id_to_string(node_id)
            score = predictions[node_id]

            if node_id in [7, 169] and score > 0.5:
                # WE HAVE PANDA
                media['panda_node_id'] = str(node_id)

                producer.send("Panda_Image_Tweets", jsonpickle.encode(twete).encode('UTF-8'), str(twete.id).encode('UTF-8'))
                break

            # print('%i : %s (score = %.5f)' % (node_id, human_string, score))

    consumer.commit_async()

producer.close()
consumer.close()

开发者ID:wannes-ds,项目名称:kafka-lab,代码行数:30,代码来源:recognize_pandas.py


注:本文中的kafka.KafkaConsumer.commit_async方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。