cloudsync.Runnable¶
- 
class 
cloudsync.Runnable¶ Abstract base class for a runnable service.
User needs to override and implement the “do” method.
- 
static 
backoff()¶ Raises an exception, interrupting the durrent do() call, and sleeping for backoff seconds.
- 
abstract 
do()¶ Override this to do something in a loop.
- 
done()¶ Cleanup code goes here. This is called when a service is stopped.
- 
in_backoff= 0.0¶ Current backoff seconds, 0.0 if not in a backoff state
- 
interruptable_sleep(secs)¶ Call this instead of sleep, so the service can be interrupted
- 
max_backoff= 1.0¶ Max backoff time in seconds
- 
min_backoff= 0.01¶ Min backoff time in seconds
- 
mult_backoff= 2.0¶ Backoff multiplier
- 
nothing_happened()¶ Sets a “nothing happened” flag. This will cause backoff to remain the same, even on success.
- 
run(*, timeout=None, until=None, sleep=0.001)¶ Calls do in a loop.
- Args:
 timeout: stop calling do after secs until: lambda returns bool sleep: seconds
If an unhandled exception occurs, backoff sleep will occur.
- 
service_name= None¶ The name of this runnable service, defaults to the class name
- 
start(*, daemon=True, **kwargs)¶ Start a thread, kwargs are passed to run()
- 
property 
started¶ True if the service has been started and has not finished stopping
- 
stop(forever=True, wait=True)¶ Stop the service, allowing any do() to complete first.
- 
static 
stop_all(runnables: List[Runnable], forever: bool = True, wait: bool = True)¶ Convenience function for stopping multiple Runnables efficiently.
- 
property 
stopped¶ Set when you call stop(), causes the services to drop out.
- 
wait(timeout=None)¶ Wait for the service to stop.
- 
wake()¶ Wake up, if do was sleeping, and do things right away.
- 
static