Skip to content

Fix issue where run_analytics() caches the timestamp key, causing Duplicate Record exceptions #119

@JSegrave-IBM

Description

@JSegrave-IBM

run_analytics() in GasExposureAnalytics.py is caching the timestamp key after the first time it's called, causing Duplicate Record exceptions on subsequent calls.

Root cause : there's a default argument in the method definition. Python default arguments are evaluated once when the function is defined, not each time the function is called. Hence the caching.

Also fixed in this PR:

  • Add some defensive code around the timestamp key, to ensure it's always (a) in UTC time and (b) does not have a timezone suffix (because mariadb does not support timezone aware timestamp datatypes).
  • Get the logging to respect the LOGLEVEL environment variable and consistently log against the filename, even if it changes (i.e. get rid of the hardcoded log names)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions