Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __setitem__(self, key, value):
if isinstance(value, dict):
value = AttrDict(value)
super().__setitem__(key, value)
async def __loader(self, file, interval, callback):
last_modified = 0
while True:
cur_mtime = os.stat(file).st_mtime
if cur_mtime != last_modified:
with open(file, 'r') as fp:
self.config = AttrDict(yaml.load(fp, Loader=yaml.FullLoader))
if callback is not None:
await callback(self.config)
last_modified = cur_mtime
await asyncio.sleep(interval)
def __init__(self, file_name):
with open(file_name) as fp:
self.config = AttrDict(yaml.load(fp, Loader=yaml.FullLoader))