memphis.py icon indicating copy to clipboard operation
memphis.py copied to clipboard

Stop consume functionality

Open Avitaltrifsik opened this issue 1 year ago • 7 comments

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 avatar Apr 04 '23 14:04 Avitaltrifsik

@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.

saivythik avatar Apr 04 '23 15:04 saivythik

Yes exactly

idanasulin2706 avatar Apr 05 '23 11:04 idanasulin2706

  • Is anyone worked on this issue, if not then I would love to work to work on this issue

Adarsh-jaiss avatar Jul 12 '23 07:07 Adarsh-jaiss

@Adarsh-jaiss The issue is available if you want to work on it. It would be much appreciated. Thank you :)

rnowling-memphis avatar Jul 29 '23 22:07 rnowling-memphis

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.

Adarsh-jaiss avatar Aug 03 '23 04:08 Adarsh-jaiss

Hi @Adarsh-jaiss it looks like that will do the job, have you already opened a PR because I couldn't find it?

idanasulin2706 avatar Aug 03 '23 05:08 idanasulin2706

@idanasulinmemphis I have mentioned this issue in the pr https://github.com/memphisdev/memphis.py/pull/193

Adarsh-jaiss avatar Aug 03 '23 06:08 Adarsh-jaiss