Reloading of weewx driver

46 views
Skip to first unread message

Bastiaan Meelberg

unread,
Jul 4, 2020, 4:28:18 PM7/4/20
to weewx-development
A question about the loading of drivers. I noticed that the weewx is reloading the driver every hour, is that correct? 
That is fine for the driver I am working on for the Weatherlink Live, but I could miss some rain because of this reload.

At this moment I store the daily_ran and current date from Davis at driver loading, then when the daily rain is increased I use the difference between the new and old value. Also with every Loop I check if the date is changed and I reset my daily rain and set the new rain value.

But if the driver is reset at midnight and it is raining, I would miss that rain. this situation is Very unlikely, but it could happen. Is there a way to prevent the driver of resetting during midnight (I think I know the answer ;-) .
Luckily the Davis also provides a 15 and 60 min last rainfall, so an extra check could be implemented is the reset was done properly.

Cheers,
Bastiaan

gjr80

unread,
Jul 4, 2020, 4:44:02 PM7/4/20
to weewx-development
Hi,

Ideally a driver should not be reloaded, though WeeWX will reload a driver under certain error conditions. This (reload) should be logged and I would expect some sort of error would also be logged. I would suggest posting a log extract covering the period a few minutes before the reload through until a few minutes after the reload.

Gary

Bastiaan Meelberg

unread,
Jul 4, 2020, 5:18:34 PM7/4/20
to weewx-development
Hi Gary,

That is very interesting! 

I looked at the log's and the reload happens when weewx.restx is doing a Shut down. I think my driver is creating the shut down due to a time out of the comsocket.

Jul  4 18:42:20 celsius weewx[900] INFO weewx.restx: MQTT: Published record 2020-07-04 18:42:20 CEST (1593880940)
Jul  4 18:42:23 celsius weewx[900] INFO weewx.restx: MQTT: Published record 2020-07-04 18:42:23 CEST (1593880943)
Jul  4 18:42:25 celsius weewx[900] INFO weewx.restx: MQTT: Published record 2020-07-04 18:42:25 CEST (1593880945)
Jul  4 18:42:28 celsius weewx[900] DEBUG urllib3.connectionpool: Starting new HTTP connection (1): 192.168.1.47:80
Jul  4 18:42:28 celsius weewx[900] DEBUG urllib3.connectionpool: http://192.168.1.47:80 "GET /v1/current_conditions HTTP/1.1" 200 None
Jul  4 18:42:28 celsius weewx[900] INFO weewx.restx: MQTT: Published record 2020-07-04 18:42:28 CEST (1593880948)
Jul  4 18:42:28 celsius weewx[900] INFO weewx.restx: MQTT: Published record 2020-07-04 18:42:28 CEST (1593880948)
Jul  4 18:42:30 celsius weewx[900] INFO weewx.restx: MQTT: Published record 2020-07-04 18:42:30 CEST (1593880950)
Jul  4 18:42:50 celsius weewx[900] INFO weewx.engine: Main loop exiting. Shutting engine down.
Jul  4 18:42:50 celsius weewx[900] INFO weewx.engine: Shutting down StdReport thread
Jul  4 18:42:50 celsius weewx[900] DEBUG weewx.engine: StdReport thread has been terminated
Jul  4 18:42:50 celsius weewx[900] DEBUG weewx.restx: Shut down MQTT thread.
Jul  4 18:42:50 celsius weewx[900] DEBUG weewx.restx: Shut down WOW thread.
Jul  4 18:42:50 celsius weewx[900] DEBUG weewx.restx: Shut down PWSWeather thread.
Jul  4 18:42:50 celsius weewx[900] DEBUG weewx.restx: Shut down Wunderground-PWS thread.
Jul  4 18:42:50 celsius weewx[900] DEBUG weewx.restx: Shut down StationRegistry thread.
Jul  4 18:42:50 celsius weewx[900] CRITICAL __main__: Caught OSError: timed out
Jul  4 18:42:50 celsius weewx[900] CRITICAL __main__:     ****  Traceback (most recent call last):
Jul  4 18:42:50 celsius weewx[900] CRITICAL __main__:     ****    File "/home/weewx/bin/weewxd", line 154, in main
Jul  4 18:42:50 celsius weewx[900] CRITICAL __main__:     ****      engine.run()
Jul  4 18:42:50 celsius weewx[900] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/engine.py", line 188, in run
Jul  4 18:42:50 celsius weewx[900] CRITICAL __main__:     ****      for packet in self.console.genLoopPackets():
Jul  4 18:42:50 celsius weewx[900] CRITICAL __main__:     ****    File "/home/weewx/bin/user/weatherlinkliveudp.py", line 414, in genLoopPackets
Jul  4 18:42:50 celsius weewx[900] CRITICAL __main__:     ****      data, wherefrom = comsocket.recvfrom(2048)
Jul  4 18:42:50 celsius weewx[900] CRITICAL __main__:     ****  socket.timeout: timed out
Jul  4 18:42:50 celsius weewx[900] CRITICAL __main__:     ****  Waiting 10 seconds then retrying...
Jul  4 18:43:00 celsius weewx[900] INFO __main__: retrying...
Jul  4 18:43:00 celsius weewx[900] INFO __main__: Using configuration file /home/weewx/weewx.conf
Jul  4 18:43:00 celsius weewx[900] INFO __main__: Debug is 1
Jul  4 18:43:00 celsius weewx[900] DEBUG __main__: Initializing engine
Jul  4 18:43:00 celsius weewx[900] INFO weewx.engine: Loading station type WeatherLinkLiveUDP (user.weatherlinkliveudp)
Jul  4 18:43:00 celsius weewx[900] INFO user.weatherlinkliveudp: WLL UDP driver version is 0.2.6
Jul  4 18:43:00 celsius weewx[900] INFO user.weatherlinkliveudp: HTTP polling interval is 10.0
Jul  4 18:43:00 celsius weewx[900] DEBUG urllib3.connectionpool: Starting new HTTP connection (1): 192.168.1.47:80

gjr80

unread,
Jul 4, 2020, 5:41:38 PM7/4/20
to weewx-development
The line you highlighted is a consequence of the error rather than the cause. When WeeWX reloads the driver WeeWX essentially does a soft restart, it shuts everything down beforehand.

Here is you error:

Jul 4 18:42:50 celsius weewx[900] CRITICAL __main__: Caught OSError: timed out
Jul 4 18:42:50 celsius weewx[900] CRITICAL __main__: **** Traceback (most recent call last):
Jul 4 18:42:50 celsius weewx[900] CRITICAL __main__: **** File "/home/weewx/bin/weewxd", line 154, in main
Jul 4 18:42:50 celsius weewx[900] CRITICAL __main__: **** engine.run()
Jul 4 18:42:50 celsius weewx[900] CRITICAL __main__: **** File "/home/weewx/bin/weewx/engine.py", line 188, in run
Jul 4 18:42:50 celsius weewx[900] CRITICAL __main__: **** for packet in self.console.genLoopPackets():
Jul 4 18:42:50 celsius weewx[900] CRITICAL __main__: **** File "/home/weewx/bin/user/weatherlinkliveudp.py", line 414, in genLoopPackets
Jul 4 18:42:50 celsius weewx[900] CRITICAL __main__: **** data, wherefrom = comsocket.recvfrom(2048)
Jul 4 18:42:50 celsius weewx[900] CRITICAL __main__: **** socket.timeout: timed out
Jul 4 18:42:50 celsius weewx[900] CRITICAL __main__: **** Waiting 10 seconds then retrying...
Jul 4 18:43:00 celsius weewx[900] INFO __main__: retrying...

If you don’t want a driver reload you need to alter weatherlinkliveudp.py to tolerate a socket.timeout error. This is a common requirement when you have a driver (or for that matter a service) that relies on an external system; your driver/service needs to be able to handle the case where the external service does not respond.

Gary

Bastiaan Meelberg

unread,
Jul 4, 2020, 5:44:02 PM7/4/20
to weewx-development
Thanks a lot! I know what to do now.
Reply all
Reply to author
Forward
0 new messages