Skip to content

Instantly share code, notes, and snippets.

@pilate
Created April 10, 2019 17:38
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 pilate/cac985a84dc69f5543034b949b22d69d to your computer and use it in GitHub Desktop.
Save pilate/cac985a84dc69f5543034b949b22d69d to your computer and use it in GitHub Desktop.
flush_timeout = 10
last_flush = timestamp()
...
if (last_flush + flush_timeout) < timestamp():
flush()
last_flush = timestamp()
# ---- OR -----
flush_timeout = 10
next_flush = timestamp() + flush_timeout
...
if next_flush < timestamp():
flush()
next_flush = timestamp() + flush_timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment