Skip to content

Commit

Permalink
rollback of utcnow changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmaeno committed Jan 11, 2024
1 parent ffe4629 commit 63dd0eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pandacommon/pandalogger/LogWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LogWrapper:
def __init__(self, log, prefix="", lineLimit=100, monToken=None, seeMem=False, hook=None):
# use timestamp as prefix
if prefix is None:
self.prefix = datetime.datetime.now(datetime.timezone.utc).isoformat("/")
self.prefix = datetime.datetime.utcnow().isoformat("/")
else:
self.prefix = prefix
# logger instance
Expand Down Expand Up @@ -37,7 +37,7 @@ def keepMsg(self, msg):
# keep max message depth
if len(self.msg_buffer) > self.line_limit:
self.msg_buffer.pop(0)
timeNow = datetime.datetime.now(datetime.timezone.utc)
timeNow = datetime.datetime.utcnow()
self.msg_buffer.append("{0} : {1}".format(timeNow.isoformat(" "), msg))

def debug(self, msg):
Expand Down
5 changes: 2 additions & 3 deletions pandacommon/pandamsgbkr/msg_bkr_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from Queue import Empty, Queue

import stomp

from pandacommon.pandalogger import logger_utils

# logger
Expand Down Expand Up @@ -720,7 +719,7 @@ def add_remover(self, headers, timeout):
# unique id for each remover
r_id = self.sub_id + "." + str(uuid.uuid4())
with self.remover_lock:
self.removers[r_id] = {"timeout": datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(seconds=timeout), "headers": copy.copy(headers)}
self.removers[r_id] = {"timeout": datetime.datetime.utcnow() + datetime.timedelta(seconds=timeout), "headers": copy.copy(headers)}
# reconnect if necessary
if self.got_disconnected:
self.restart()
Expand All @@ -734,7 +733,7 @@ def purge_removers(self):
"""
self.logger.debug("purging old removers")
with self.remover_lock:
time_now = datetime.datetime.now(datetime.timezone.utc)
time_now = datetime.datetime.utcnow()
n_old = len(self.removers)
for r_id in list(self.removers):
timeout = self.removers[r_id]["timeout"]
Expand Down
4 changes: 2 additions & 2 deletions pandacommon/pandautils/thread_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ def __getitem__(self, item):

def __setitem__(self, item, value):
with self.lock:
dict.__setitem__(self, item, {"time_stamp": datetime.datetime.now(datetime.timezone.utc), "data": value})
dict.__setitem__(self, item, {"time_stamp": datetime.datetime.utcnow(), "data": value})

# check data by taking freshness into account
def __contains__(self, item):
with self.lock:
try:
ret = dict.__getitem__(self, item)
if ret["time_stamp"] > datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(minutes=self.timeout):
if ret["time_stamp"] > datetime.datetime.utcnow() - datetime.timedelta(minutes=self.timeout):
return True
except Exception:
pass
Expand Down

0 comments on commit 63dd0eb

Please sign in to comment.