From 0fabc906d1a5f586307ee5ee527c7eacbef5b8fc Mon Sep 17 00:00:00 2001 From: bingwang-ms <66248323+bingwang-ms@users.noreply.github.com> Date: Fri, 25 Sep 2020 20:19:18 +0800 Subject: [PATCH] Fix exception when attempting to write a datetime to db (#5467) redis-py 3.0 used in master branch only accepts user data as bytes, strings or numbers (ints, longs and floats). Attempting to specify a key or a value as any other type will raise a DataError exception. This PR address the issue bt converting datetime to str --- files/image_config/procdockerstatsd/procdockerstatsd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/image_config/procdockerstatsd/procdockerstatsd b/files/image_config/procdockerstatsd/procdockerstatsd index 00501f8100..b7dd1705db 100755 --- a/files/image_config/procdockerstatsd/procdockerstatsd +++ b/files/image_config/procdockerstatsd/procdockerstatsd @@ -184,9 +184,9 @@ class ProcDockerStats(daemon_base.DaemonBase): self.update_dockerstats_command() datetimeobj = datetime.now() # Adding key to store latest update time. - self.update_state_db('DOCKER_STATS|LastUpdateTime', 'lastupdate', datetimeobj) + self.update_state_db('DOCKER_STATS|LastUpdateTime', 'lastupdate', str(datetimeobj)) self.update_processstats_command() - self.update_state_db('PROCESS_STATS|LastUpdateTime', 'lastupdate', datetimeobj) + self.update_state_db('PROCESS_STATS|LastUpdateTime', 'lastupdate', str(datetimeobj)) # Data need to be updated every 2 mins. hence adding delay of 120 seconds time.sleep(120)