Skip to content

Instantly share code, notes, and snippets.

@whardier
Last active June 22, 2020 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whardier/0139fe4eae9b900ea0565e21b8178f47 to your computer and use it in GitHub Desktop.
Save whardier/0139fe4eae9b900ea0565e21b8178f47 to your computer and use it in GitHub Desktop.
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