0

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?

kittu
  • 3
  • 3
  • Use the `.stop()` method to stop the `PeriodicCallback`. Maybe keep a counter of number of retries somewhere. – xyres Jan 21 '22 at 17:22
  • Right? I was overthinking and was reading documentation to find if there is any existing "timeout" functionality provided in tornado. But meh. Thanks for the suggestion and i implemented your suggestion !! – kittu Jan 31 '22 at 14:10

0 Answers0