mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-04-08 14:08:17 -07:00
WebHost: Update UTC datetime usage (timezone-naive) (#4906)
This commit is contained in:
11
Utils.py
11
Utils.py
@@ -18,6 +18,8 @@ import logging
|
||||
import warnings
|
||||
|
||||
from argparse import Namespace
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from settings import Settings, get_settings
|
||||
from time import sleep
|
||||
from typing import BinaryIO, Coroutine, Optional, Set, Dict, Any, Union, TypeGuard
|
||||
@@ -1291,6 +1293,15 @@ def is_iterable_except_str(obj: object) -> TypeGuard[typing.Iterable[typing.Any]
|
||||
return isinstance(obj, typing.Iterable)
|
||||
|
||||
|
||||
def utcnow() -> datetime:
|
||||
"""
|
||||
Implementation of Python's datetime.utcnow() function for use after deprecation.
|
||||
Needed for timezone-naive UTC datetimes stored in databases with PonyORM (upstream).
|
||||
https://ponyorm.org/ponyorm-list/2014-August/000113.html
|
||||
"""
|
||||
return datetime.now(timezone.utc).replace(tzinfo=None)
|
||||
|
||||
|
||||
class DaemonThreadPoolExecutor(concurrent.futures.ThreadPoolExecutor):
|
||||
"""
|
||||
ThreadPoolExecutor that uses daemonic threads that do not keep the program alive.
|
||||
|
||||
Reference in New Issue
Block a user