Opened 6 years ago

Last modified 5 years ago

#3627 enhancement new

TimerService can stop without notice

Reported by: amaury Owned by: amaury
Priority: normal Milestone:
Component: core Keywords:
Cc: exarkun Branch:
Author: Launchpad Bug:

Description

When the TimerService function fails (either with an exception or by returning a deferred that will errback) the internal LoopingCall stops.

But there is no way for the application to handle this, at least with a public API.
the service.running attribute is still true!
Now I see two workarounds:

  • periodically check service._loop.running
  • override TimerService._failed and handle the error there.

But I'd prefer a more official way to do this (i.e. without leading underscores).

A solution could be to force a TimerService to stop when the LoopingCall terminates. I suggest the change TimerService._failed like this:

    def _failed(self, why):
        self.stopService()
        log.err(why)

This also removes the need for the "self._loop.running = False" statement.

Change History (2)

comment:1 Changed 5 years ago by exarkun

  • Cc exarkun added

Calling stopService doesn't seem like it will help anyone. How would an application determine that the timer stopped due to an error, rather than as part of system shutdown?

It is tempting to say that the function passed to TimerService simply should not raise an exception. Then you never have to worry about the subsequent behavior in that case.

comment:2 Changed 5 years ago by glyph

  • Owner changed from glyph to amaury
Note: See TracTickets for help on using tickets.