fix: revert use of dt.UTC to dt.tz.UTC
some instance still on python 3.9
This commit is contained in:
parent
905bdd1a58
commit
cdbf152f40
4 changed files with 10 additions and 10 deletions
|
@ -27,12 +27,12 @@ def update_smart_proxy_instance(group_id: int,
|
|||
).first()
|
||||
if instance is None:
|
||||
instance = SmartProxy()
|
||||
instance.added = datetime.datetime.now(datetime.UTC)
|
||||
instance.added = datetime.datetime.now(datetime.timezone.utc)
|
||||
instance.group_id = group_id
|
||||
instance.provider = provider
|
||||
instance.region = region
|
||||
db.session.add(instance)
|
||||
instance.updated = datetime.datetime.now(datetime.UTC)
|
||||
instance.updated = datetime.datetime.now(datetime.timezone.utc)
|
||||
instance.instance_id = instance_id
|
||||
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ def auto_deprecate_proxies() -> None:
|
|||
.all())
|
||||
logging.debug("Max age: %s", max_age_proxies)
|
||||
for proxy in max_age_proxies:
|
||||
max_age_cutoff = datetime.datetime.now(datetime.UTC) - datetime.timedelta(
|
||||
max_age_cutoff = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(
|
||||
days=1, seconds=86400 * random.random()) # nosec: B311
|
||||
if proxy.added < max_age_cutoff:
|
||||
proxy.deprecate(reason="max_age_reached")
|
||||
|
@ -168,7 +168,7 @@ def destroy_expired_proxies() -> None:
|
|||
This function finds all proxies that are not already destroyed and have been deprecated for more than 4 days.
|
||||
It then destroys these proxies.
|
||||
"""
|
||||
expiry_cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=4)
|
||||
expiry_cutoff = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=4)
|
||||
proxies = Proxy.query.filter(
|
||||
Proxy.destroyed.is_(None),
|
||||
Proxy.deprecated < expiry_cutoff
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue