memphis.py
memphis.py copied to clipboard
Stop consume functionality
We want users to make use of the consumer.consume function, will be able to stop the automatic consumption. So we need a new function consumer.stopConsume which will be responsible to do so.
@Avitaltrifsik , i have to make use the consumer.consume function and create a new function named consumer.stopconsume which stop automatic consumption. plz correct me if i am wrong.
Yes exactly
- Is anyone worked on this issue, if not then I would love to work to work on this issue
@Adarsh-jaiss The issue is available if you want to work on it. It would be much appreciated. Thank you :)
Hey @Avitaltrifsik , I have created a stopConsume method with self parameter. kindly have a look into this:
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.
Hi @Adarsh-jaiss it looks like that will do the job, have you already opened a PR because I couldn't find it?
@idanasulinmemphis I have mentioned this issue in the pr https://github.com/memphisdev/memphis.py/pull/193