From 413893e0361aff43115ce93b918c5ce320ceb072 Mon Sep 17 00:00:00 2001 From: Kevin Kirsche Date: Thu, 11 Aug 2022 13:30:49 -0400 Subject: [PATCH] fix: outdate method of creating utc timestamps This fixes the usage of replace with `utcnow` with the recommendation from https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow --- asyncpool/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/asyncpool/__init__.py b/asyncpool/__init__.py index 8898b4a..2c6dbd4 100644 --- a/asyncpool/__init__.py +++ b/asyncpool/__init__.py @@ -2,8 +2,7 @@ from datetime import datetime, timezone def utc_now(): - # utcnow returns a naive datetime, so we have to set the timezone manually - return datetime.utcnow().replace(tzinfo=timezone.utc) + return datetime.now(tz=timezone.utc) class Terminator: pass @@ -151,4 +150,4 @@ async def join(self): self._logger.debug('Completed {}'.format(self._name)) if self._exceptions and self._raise_on_join: - raise Exception("Exception occurred in pool {}".format(self._name)) \ No newline at end of file + raise Exception("Exception occurred in pool {}".format(self._name))