Skip to content

Instantly share code, notes, and snippets.

@duckythescientist
duckythescientist / periodic.py
Created July 10, 2015 17:58
Periodically run Python function asynchronously in the background of a script
#!/usr/bin/env python2
from threading import Event, Thread
class Periodic(object):
"""Periodically run a function with arguments asynchronously in the background
Period is a float of seconds.
Don't expect exact precision with timing.
Threading is used instead of Multiprocessing because we need shared memory