Mercurial > personal > weather-server
comparison weather_server/locations.py @ 24:20c8ec56e447
logfile: Pull logfile thread out of Logger.
This enables automatic garbage collection of Logger instances,
since a running thread no longer has a reference to a Logger's self.
It separates exclusive management of logfile state into the
_writer_thread function, which now opens the file and writes it until
it is told to stop by receiving the poison pill.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 10 Nov 2019 23:07:11 -0500 |
parents | e229afdd447b |
children | 7def5611895b |
comparison
equal
deleted
inserted
replaced
23:88249e451566 | 24:20c8ec56e447 |
---|---|
29 parser.read_file(infile) | 29 parser.read_file(infile) |
30 self.name = parser.get( | 30 self.name = parser.get( |
31 'location', 'name', fallback='Weather station') | 31 'location', 'name', fallback='Weather station') |
32 self.tz_name = parser.get('location', 'timezone', fallback='UTC') | 32 self.tz_name = parser.get('location', 'timezone', fallback='UTC') |
33 self.password = parser.get('location', 'password') | 33 self.password = parser.get('location', 'password') |
34 self.logger = logfile.Logger.create( | 34 self.logger = logfile.Logger( |
35 str(root / LOG), sample_field='sample_time') | 35 str(root / LOG), sample_field='sample_time') |
36 except (IOError, KeyError, configparser.Error): | 36 except (IOError, KeyError, configparser.Error): |
37 raise ConfigError("Couldn't load location info.") | 37 raise ConfigError("Couldn't load location info.") |
38 | 38 |
39 def record( | 39 def record( |