Open bellrichm opened 1 year ago
One solution When data is received (the on message callbacks), if the field is in the cache remove it. This would be near the call to _update_data method. I don’t like this because it spreads the interaction of the cache across the code base.
I thought about a separate cache service, but due to record_augmentation happening in stdArchive service, it would run into the same challenge that the cache would have to be cleared at the ‘loop level’. About the only benefit is separation of concerns.
Function test would be something like this
Some of these checks might not be necessary. Also might be separate into smaller chunks.
It is actually very broken in at least this one scenario:
WeeWX record_generation = hardware record_augmentation = True # obviously if this is False, then this would never work
MQTTSubscribe is running as a service expires_after = None binding = loop
This is a timing issue. Both MQTTSubscribe and StdArchive bind to ‘NEW_ARCHIVE_RECORD’ event. MQTTSubscribe handles it first. It looks at the archive record and sees that the data is missing. It then pulls the data from the cache (note, the value could be None). Then StdArchive handles the event. It looks at the archive record and sees that the field has a value (note, again the value could be None) and therefore does not augment the record. The result is the archive record always gets the value from the cache.