Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: If attribute CLOCK_BOOTTIME doesn't exist fall back #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion oauth2_clientd/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def token_needs_refreshing(token: Dict[str, Any], threshold: int) -> bool:
return token['expires_at'] + threshold > time.time()

def get_boottime() -> int:
return int(time.clock_gettime(time.CLOCK_BOOTTIME))
try:
val = int(time.clock_gettime(time.CLOCK_BOOTTIME))
except AttributeError:
val = int(time.clock_gettime(time.CLOCK_MONOTONIC))
return val

# This is a workaround. All implementations of sleep() in Python use
# CLOCK_MONOTONIC, which has the advantage of never going backward but it
Expand Down