remove acquire() and release() functions and run the threads as deamons for easier cleanups

This commit is contained in:
Sven Czarnian
2021-11-15 17:33:26 +01:00
parent 2d3384f0aa
commit e4ce4ff654
4 changed files with 16 additions and 106 deletions

View File

@@ -11,15 +11,9 @@ from aman.com.DwdCrawler import DwdCrawler
import aman.config.Weather
class Weather(Thread):
def __init__(self):
def __init__(self, config : aman.config.Weather.Weather):
Thread.__init__(self)
self.NextUpdate = None
self.LastUpdateTried = None
self.StopThread = False
self.Provider = None
def acquire(self, config : aman.config.Weather.Weather):
self.NextUpdate = dt.utcfromtimestamp(int(time.time()))
self.LastUpdateTried = None
self.StopThread = False
@@ -31,12 +25,9 @@ class Weather(Thread):
sys.stderr.write('Invalid or unknown weather-provider defined')
sys.exit(-1)
self.setDaemon(True)
self.start()
def release(self):
self.StopThread = True
self.join()
def currentClock():
clock = dt.utcfromtimestamp(int(time.time())).replace(tzinfo = pytz.UTC)
return clock