From c1acb2c052514872ba55cdf6ccc6b3a18189a139 Mon Sep 17 00:00:00 2001 From: Thomas Ward Date: Mon, 18 Nov 2024 12:28:26 -0500 Subject: [PATCH 1/2] ws.py: Actually remove remaining datetime.datetime.utcnow() entries --- ws.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ws.py b/ws.py index 07ea850be7..c003da3bbd 100755 --- a/ws.py +++ b/ws.py @@ -21,7 +21,7 @@ import traceback from bodyfetcher import BodyFetcher import chatcommunicate -from datetime import datetime +from datetime import datetime, UTC from spamhandling import check_if_spam_json from globalvars import GlobalVars from datahandling import (load_pickle, PICKLE_STORAGE, load_files, filter_auto_ignored_posts, @@ -232,7 +232,7 @@ def check_socket_connections(): socket_failure = False with chatcommunicate._clients_lock: for client in chatcommunicate._clients.values(): - if client.last_activity and (datetime.utcnow() - client.last_activity).total_seconds() >= 60: + if client.last_activity and (datetime.now(UTC) - client.last_activity).total_seconds() >= 60: socket_failure = True if socket_failure: exit_mode("socket_failure") @@ -319,7 +319,7 @@ def init_se_websocket_or_reboot(max_tries, tell_debug_room_on_error=False): except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() - now = datetime.utcnow() + now = datetime.now(UTC) delta = now - GlobalVars.startup_utc_date seconds = delta.total_seconds() tr = traceback.format_exc() From 5d96e7302d89b4f428cce590dbdce9e4e77f679d Mon Sep 17 00:00:00 2001 From: Thomas Ward Date: Mon, 18 Nov 2024 12:33:29 -0500 Subject: [PATCH 2/2] Python 3.10 compatibility. --- ws.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ws.py b/ws.py index c003da3bbd..01fc248f7e 100755 --- a/ws.py +++ b/ws.py @@ -21,7 +21,7 @@ import traceback from bodyfetcher import BodyFetcher import chatcommunicate -from datetime import datetime, UTC +from datetime import datetime, timezone from spamhandling import check_if_spam_json from globalvars import GlobalVars from datahandling import (load_pickle, PICKLE_STORAGE, load_files, filter_auto_ignored_posts, @@ -232,7 +232,7 @@ def check_socket_connections(): socket_failure = False with chatcommunicate._clients_lock: for client in chatcommunicate._clients.values(): - if client.last_activity and (datetime.now(UTC) - client.last_activity).total_seconds() >= 60: + if client.last_activity and (datetime.now(timezone.utc) - client.last_activity).total_seconds() >= 60: socket_failure = True if socket_failure: exit_mode("socket_failure") @@ -319,7 +319,7 @@ def init_se_websocket_or_reboot(max_tries, tell_debug_room_on_error=False): except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() - now = datetime.now(UTC) + now = datetime.now(timezone.utc) delta = now - GlobalVars.startup_utc_date seconds = delta.total_seconds() tr = traceback.format_exc()