2 years ago

#74487

test-img

kittu

How to stop tornado.ioloop PeriodicCallback after certain retries

I am new to using tornado, struggling with a scenario when the periodic callback is made to github if for any reason github service is not reachable then IOloop.PeriodicCallBack is stuck is infinite loop. Even when the github service is restored it seems the original thread's context is lost, though the periodic callback is happening its in infinite loop.

Here is the snippet

        def periodic_cb():
            logger.info("Periodic Callback.....")
            self.write(" .....{}".format(self.obj.processed_vars_count)) #writing this to front-end; not important
            self.flush()

        pc = PeriodicCallback(periodic_cb, 5000) #retrying periodiccallback every 5 second
        pc.start()

I want to do certain number of retries i.e. new retry every time by closing the previous loop stop the periodiccallback after 5 minutes. Can someone please share your thoughts?

async-await

tornado

ioloop

0 Answers

Your Answer

Accepted video resources