Last active
June 22, 2020 02:48
-
-
Save whardier/0139fe4eae9b900ea0565e21b8178f47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import json | |
import pathlib | |
configurable_mtime = 0 | |
configurable_path = pathlib.Path('/tmp/configurable.json') | |
configurable = {} | |
counter = 0 | |
def something(): | |
global counter | |
counter += 1 | |
print(time.time(), counter) | |
while True: | |
if configurable_path.exists(): | |
mtime = configurable_path.stat().st_mtime | |
if configurable_mtime != mtime: | |
configurable_mtime = mtime | |
with configurable_path.open() as fd: | |
configurable = json.load(fd) | |
something() | |
time.sleep(configurable.get('the_while_loop_delay', 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment