本文整理汇总了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()