From 100a3c77987d329980fe92c3f03b90c04d25bd42 Mon Sep 17 00:00:00 2001 From: sankalp_j Date: Tue, 12 Feb 2019 17:43:55 +0530 Subject: [PATCH] removed build folder --- build/lib/timeloop/__init__.py | 1 - build/lib/timeloop/app.py | 65 -------------------------------- build/lib/timeloop/exceptions.py | 6 --- build/lib/timeloop/helpers.py | 4 -- build/lib/timeloop/job.py | 19 ---------- 5 files changed, 95 deletions(-) delete mode 100644 build/lib/timeloop/__init__.py delete mode 100644 build/lib/timeloop/app.py delete mode 100644 build/lib/timeloop/exceptions.py delete mode 100644 build/lib/timeloop/helpers.py delete mode 100644 build/lib/timeloop/job.py diff --git a/build/lib/timeloop/__init__.py b/build/lib/timeloop/__init__.py deleted file mode 100644 index 8d95c4d..0000000 --- a/build/lib/timeloop/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from timeloop.app import Timeloop diff --git a/build/lib/timeloop/app.py b/build/lib/timeloop/app.py deleted file mode 100644 index d6808d1..0000000 --- a/build/lib/timeloop/app.py +++ /dev/null @@ -1,65 +0,0 @@ -import logging -import sys -import signal -import time - -from timeloop.exceptions import ServiceExit -from timeloop.job import Job -from timeloop.helpers import service_shutdown - - -class Timeloop(): - def __init__(self): - self.jobs = [] - logger = logging.getLogger('timeloop') - ch = logging.StreamHandler(sys.stdout) - ch.setLevel(logging.INFO) - formatter = logging.Formatter('[%(asctime)s] [%(name)s] [%(levelname)s] %(message)s') - ch.setFormatter(formatter) - logger.addHandler(ch) - logger.setLevel(logging.INFO) - self.logger = logger - - def _add_job(self, func, interval, *args, **kwargs): - j = Job(interval, func, *args, **kwargs) - self.jobs.append(j) - - def _block_main_thread(self): - signal.signal(signal.SIGTERM, service_shutdown) - signal.signal(signal.SIGINT, service_shutdown) - - while True: - try: - time.sleep(1) - except ServiceExit: - self.stop() - break - - def _start_jobs(self, block): - for j in self.jobs: - j.daemon = not block - j.start() - self.logger.info("Registered job {}".format(j.execute)) - - def _stop_jobs(self): - for j in self.jobs: - self.logger.info("Stopping job {}".format(j.execute)) - j.stop() - - def job(self, interval): - def decorator(f): - self._add_job(f, interval) - return f - return decorator - - def stop(self): - self._stop_jobs() - self.logger.info("Timeloop exited.") - - def start(self, block=False): - self.logger.info("Starting Timeloop..") - self._start_jobs(block=block) - - self.logger.info("Timeloop now started. Jobs will run based on the interval set") - if block: - self._block_main_thread() diff --git a/build/lib/timeloop/exceptions.py b/build/lib/timeloop/exceptions.py deleted file mode 100644 index 4585852..0000000 --- a/build/lib/timeloop/exceptions.py +++ /dev/null @@ -1,6 +0,0 @@ -class ServiceExit(Exception): - """ - Custom exception which is used to trigger the clean exit - of all running threads and the main program. - """ - pass diff --git a/build/lib/timeloop/helpers.py b/build/lib/timeloop/helpers.py deleted file mode 100644 index 01b22e8..0000000 --- a/build/lib/timeloop/helpers.py +++ /dev/null @@ -1,4 +0,0 @@ -from timeloop.exceptions import ServiceExit - -def service_shutdown(signum, frame): - raise ServiceExit diff --git a/build/lib/timeloop/job.py b/build/lib/timeloop/job.py deleted file mode 100644 index df97d2f..0000000 --- a/build/lib/timeloop/job.py +++ /dev/null @@ -1,19 +0,0 @@ -from threading import Thread, Event -from datetime import timedelta - -class Job(Thread): - def __init__(self, interval, execute, *args, **kwargs): - Thread.__init__(self) - self.stopped = 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)