I am referring to this tutorial for kafka which I have changed the video frames to image inputs. In my case, consumer.poll() does not return anything and breaks out of the code. In the docker terminal displays this:
kafka1 | [2023-01-10 07:21:30,719] INFO [GroupCoordinator 1]: Dynamic member with unknown member id joins group kafka-cam in Empty state. Created a new member id rdkafka-f0ea3fd0-2eef-494d-bbe5-1acd9db067c4 and request the member to rejoin with this id. (kafka.coordinator.group.GroupCoordinator)
kafka1 | [2023-01-10 07:21:30,721] INFO [GroupCoordinator 1]: Preparing to rebalance group kafka-cam in state PreparingRebalance with old generation 0 (__consumer_offsets-24) (reason: Adding new member rdkafka-f0ea3fd0-2eef-494d-bbe5-1acd9db067c4 with group instance id None; client reason: not provided) (kafka.coordinator.group.GroupCoordinator)
kafka1 | [2023-01-10 07:21:33,722] INFO [GroupCoordinator 1]: Stabilized group kafka-cam generation 1 (__consumer_offsets-24) with 1 members (kafka.coordinator.group.GroupCoordinator)(kafka.coordinator.group.GroupCoordinator)
But it does not actually run the code below:
while True:
print("entered")
msg = consumer.poll(100)
print(msg)
if msg == None:
continue
as consumer.poll exits the entire code as a whole and does not run anything after that.
According to the printing statements I have added for testing purposes, msg should either return None or the value of whatever the consumer polls. However, it breaks out of the code.
python consumer.py
Creating consumer thread...
Starting the consumer thread...
entered
As shown above, it prints entered but does not run the print(msg) after calling poll.
The poll function should only return None or msg, otherwise throw an exception. It should not break out of the code. Anyone experiencing this issue? I might be doing something wrong as this is the first time I am using kafka.
source https://stackoverflow.com/questions/75066634/confluent-kafka-python-consumer-poll-function-exits-the-entire-code
Comments
Post a Comment