memphis.py
memphis.py copied to clipboard
stop consume functionality
I have created a stopConsume method with self parameter, refefered in the issue #139
def stopConsume(self):
if self.t_consume is not None:
self.t_consume.cancel()
self.t_consume = None
In this code :
-
The stopConsume method is added to the Consumer class. This method will cancel the task responsible for consuming messages, effectively stopping the automatic message consumption.
-
In the __consume method, we added a condition to check whether the consumer task (t_consume) is still running. If not, it will break out of the loop, ensuring that the consumption stops when stopConsume is called.