Skip to content

Instantly share code, notes, and snippets.

@VyBui
Created April 9, 2020 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VyBui/b3094d06bb3e52114535e3c763c8826f to your computer and use it in GitHub Desktop.
Save VyBui/b3094d06bb3e52114535e3c763c8826f to your computer and use it in GitHub Desktop.
from time import sleep
from json import dumps
from kafka import KafkaProducer
BPS_models = '/home/vybt/Downloads/release_official/full_flow_test/models.txt'
producer = KafkaProducer(bootstrap_servers=['localhost:9092'],
value_serializer=lambda x:
dumps(x).encode('utf-8'))
txt_file = open(BPS_models, "r")
count = 0
for person_url in txt_file:
data = {'imagePersonURL' : str(person_url), 'ownerId': int(count)}
count += 1
print("sending ... {}".format(count))
producer.send('bpsIn', value=data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment