Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JSegrave-IBM opened this issue Nov 2, 2020 · 0 comments
Assignees
Labels
bug Something isn't working developer

Comments

@JSegrave-IBM
Copy link
Collaborator

JSegrave-IBM commented Nov 2, 2020

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)
@JSegrave-IBM JSegrave-IBM added bug Something isn't working developer labels Nov 2, 2020
@JSegrave-IBM JSegrave-IBM self-assigned this Nov 2, 2020
@JSegrave-IBM JSegrave-IBM changed the title Fix issue where run_analytics() caches the timestamp key, causing Duplicate Key exceptions Fix issue where run_analytics() caches the timestamp key, causing Duplicate Record exceptions Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working developer
Projects
None yet
Development

No branches or pull requests

1 participant