Skip to content

Commit

Permalink
Drop Python 3.2 compatibility shim
Browse files Browse the repository at this point in the history
  • Loading branch information
matyasselmeci committed May 29, 2024
1 parent e44ebba commit f304c24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
9 changes: 0 additions & 9 deletions src/webapp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import re
import subprocess
import sys
import time
from typing import Any, Dict, List, Union, AnyStr, NewType, TypeVar
from functools import wraps

Expand Down Expand Up @@ -395,14 +394,6 @@ def wrapped():
return wrapped


def get_timestamp():
"""Return a monotonic timestamp if available, otherwise a wall-clock timestamp."""
if hasattr(time, "monotonic"):
return time.monotonic()
else:
return time.time()


XROOTD_CACHE_SERVER = "XRootD cache server"
XROOTD_ORIGIN_SERVER = "XRootD origin server"
GRIDTYPE_1 = "OSG Production Resource"
Expand Down
11 changes: 6 additions & 5 deletions src/webapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import logging
import os
import time
from typing import Dict, Set, List, Optional

import yaml
Expand All @@ -23,7 +24,7 @@ def time(self):


from webapp import common, contacts_reader, ldap_data, mappings, project_reader, rg_reader, vo_reader
from webapp.common import readfile, get_timestamp
from webapp.common import readfile
from webapp.contacts_reader import ContactsData
from webapp.topology import Topology, Downtime
from webapp.vos_data import VOsData
Expand Down Expand Up @@ -52,16 +53,16 @@ def should_update(self):
"""Return True if we should update, either because we're past the next update time
or because force_update is True.
"""
return self.force_update or not self.data or get_timestamp() > self.next_update
return self.force_update or not self.data or time.monotonic() > self.next_update

def try_again(self):
"""Set the next update time to now + the retry delay."""
self.next_update = get_timestamp() + self.retry_delay
self.next_update = time.monotonic() + self.retry_delay

def update(self, data):
"""Cache new data and set the next update time to now + the cache lifetime."""
self.data = data
self.timestamp = get_timestamp()
self.timestamp = time.monotonic()
self.next_update = self.timestamp + self.cache_lifetime
self.force_update = False

Expand Down Expand Up @@ -162,7 +163,7 @@ def maybe_update_topology_repo(self) -> bool:
with topology_git_update_summary.time():
ok = self._update_topology_repo()
if ok:
self.topology_repo_stamp.update(get_timestamp())
self.topology_repo_stamp.update(time.monotonic())
return True
else:
self.topology_repo_stamp.try_again()
Expand Down

0 comments on commit f304c24

Please sign in to comment.