On Thursday, January 19, 2017 at 9:19:44 PM UTC-8, mwall wrote:
> Also I'll add in the suggestion for the systemctl file. In the 'readme' I >> mention that you should put in references to make sure the network is up >> and running so the Weewx daemon will not cause problems on startup. >> > > it would be better if you do not. instead of applying that band-aid, make > the driver more robust. you should retry the network connections, and if > the retries fail more than max_tries times, then you raise a > weewx.WeeWxIOError exception. then weewx handles it as it does for any > other driver. > > remember that not everyone uses systemd (*bsd, windows and macos do not > even have systemd) > Here's the error message that I get when my wifi goes down: Jan 18 20:07:14 rpi weewx[26548]: engine: Caught unrecoverable exception in engine: Jan 18 20:07:14 rpi weewx[26548]: **** [Errno 101] Network is unreachable Jan 18 20:07:14 rpi weewx[26548]: **** Traceback (most recent call last): Jan 18 20:07:14 rpi weewx[26548]: **** File "/usr/share/weewx/weewx/engine.py", line 847, in main Jan 18 20:07:14 rpi weewx[26548]: **** engine.run() Jan 18 20:07:14 rpi weewx[26548]: **** File "/usr/share/weewx/weewx/engine.py", line 186, in run Jan 18 20:07:14 rpi weewx[26548]: **** for packet in self.console.genLoopPackets(): Jan 18 20:07:14 rpi weewx[26548]: **** File "/usr/share/weewx/user/xc0422.py", line 128, in genLoopPackets Jan 18 20:07:14 rpi weewx[26548]: **** (self.ipAddressMask, UDP_BROADCAST_PORT)) Jan 18 20:07:14 rpi weewx[26548]: **** error: [Errno 101] Network is unreachable Jan 18 20:07:14 rpi weewx[26548]: **** Exiting. Jan 18 20:08:15 rpi weewx[26838]: engine: Initializing weewx version 3.6.2 Clearly the sock.sendto failed here, since the wifi went down and there was no network at that point. weewx then crashes, and a minute later systemd started it up again. (And it probably got to that point because the recv further down the while loop failed.) So a try, except bracketing the sendto would help. With a configurable delay? With a configurable number of retries? But I've really got to figure out why my cable modem apparently periodically restarts.
