Skip to content

Commit

Permalink
Use time.monotonic on py3.3+
Browse files Browse the repository at this point in the history
On Python 3.3 or newer, `monotonic` module aliases `time.monotonic`
from the standard library. On older versions, it will fall back to
an equivalent platform specific implementation provided by the
`monotonic` module.
Attempting to import `time.monotonic` right off the bat removes
the need for additional dependency on modern python installations.
  • Loading branch information
MichalHaluza committed Dec 2, 2022
1 parent cceaae9 commit 00d2899
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion fastpurge/_client.py
Expand Up @@ -7,12 +7,16 @@

import requests

try:
from time import monotonic
except ImportError: # pragma: no cover
from monotonic import monotonic

from six import string_types
from six.moves.urllib.parse import urljoin

from akamai.edgegrid import EdgeGridAuth
from akamai.edgegrid.edgerc import EdgeRc
from monotonic import monotonic
from more_executors import Executors
from more_executors.futures import f_sequence

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,5 +1,5 @@
requests
more-executors>=2.7.0
six
monotonic
monotonic; python_version < '3.3'
edgegrid-python
5 changes: 4 additions & 1 deletion tests/test_purge.py
Expand Up @@ -2,7 +2,10 @@
import requests_mock
import mock

from monotonic import monotonic
try:
from time import monotonic
except ImportError:
from monotonic import monotonic

from fastpurge import FastPurgeClient, FastPurgeError

Expand Down

0 comments on commit 00d2899

Please sign in to comment.