X-Git-Url: https://defiant.homedns.org/gitweb/?a=blobdiff_plain;f=scheduler.py;h=d372407f73f1fca2c6f4732c8f931db2c7802826;hb=2056613e07dc73a25e8426a6ca67fccc88e13fee;hp=8310a6d2d541863ba1976f56a5d3f0cd3669f26d;hpb=f0049295539f8ac6c298f53b0557ea0545b41777;p=pyshared.git diff --git a/scheduler.py b/scheduler.py index 8310a6d..d372407 100755 --- a/scheduler.py +++ b/scheduler.py @@ -13,7 +13,6 @@ class Scheduler: self.lThreads = [] self.pause = False self.autoclean() - self.__lock_delay = threading.Lock() def autoclean(self): logger.debug("Current number of threads: %d" % threading.active_count()) @@ -34,21 +33,19 @@ class Scheduler: t.setDaemon(True) t.setName(str(function)) k[1] = t - t.delayed = True t.start() self.lThreads.append(t) def dispatch(self, function, timer, args, kwargs): + timer.timeup = True while True: - with self.__lock_delay: - still_running = False - for t in self.lThreads: - if t.name == str(function) and t.isAlive() and t.ident != timer.ident and not t.delayed: - still_running = True - break - if not still_running: - t.delayed = False + still_running = False + for t in self.lThreads: + if t.name == str(function) and t.isAlive() and t.ident != timer.ident: + still_running = True break + if not still_running: + break logger.debug("Delaying execution of Thread %s", t.name) # Another Thread still running, delay execution sleep(0.1)