# Copyright 2014 varnishapi authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

import time

from feaas import storage


class Base(object):

    def __init__(self, manager, interval, *locks):
        self.manager = manager
        self.storage = manager.storage
        self.interval = interval

    def init_locker(self, *lock_names):
        self.locker = storage.MultiLocker(self.storage)
        for lock_name in lock_names:
            self.locker.init(lock_name)

    def loop(self):
        self.running = True
        while self.running:
            self.run()
            time.sleep(self.interval)

    def stop(self):
        self.running = False

[((18, 22, 18, 55), 'feaas.storage.MultiLocker', 'storage.MultiLocker', ({(18, 42, 18, 54): 'self.storage'}, {}), '(self.storage)', False, 'from feaas import storage\n'), ((26, 12, 26, 37), 'time.sleep', 'time.sleep', ({(26, 23, 26, 36): 'self.interval'}, {}), '(self.interval)', False, 'import time\n')]