ai-station/.venv/lib/python3.12/site-packages/posthog/poller.py

21 lines
595 B
Python
Raw Normal View History

2025-12-25 14:54:33 +00:00
import threading
class Poller(threading.Thread):
def __init__(self, interval, execute, *args, **kwargs):
threading.Thread.__init__(self)
self.daemon = True # Make daemon to not interfere with program exit
self.stopped = threading.Event()
self.interval = interval
self.execute = execute
self.args = args
self.kwargs = kwargs
def stop(self):
self.stopped.set()
self.join()
def run(self):
while not self.stopped.wait(self.interval.total_seconds()):
self.execute(*self.args, **self.kwargs)