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

time.clock() -> time.process_time() #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zariuq
Copy link

@zariuq zariuq commented Jul 5, 2022

Apparently, time.clock() was removed in Python 3.8.

I followed the advice in https://stackoverflow.com/questions/58569361/attributeerror-module-time-has-no-attribute-clock-in-python-3-8

@RandomOrg
Copy link
Owner

Hello,

Apologies for the delay on replying - we appreciate your efforts and interest in improving this library!

We are aware that the time.clock() function has been removed, however in order to maintain support for older versions of Python, namely Python 2.7, we need to keep it in the library. The call is surrounded by a try-except clause, meaning that when running the code in a version which no longer supports time.clock(), time.process_time() is called instead.

Changing time.clock() to time.process_time() in these cases would make the code in both the try and except blocks identical:

try:
     # Python 2.7
     if self._requests_left is None or \
-         time.clock() > (self._last_response_received_time
+         time.process_time() > (self._last_response_received_time 
                       + _ALLOWANCE_STATE_REFRESH_SECONDS):
         self._get_usage()
except AttributeError:
      # Python 3.3+
      if self._requests_left is None or \
         time.process_time() > (self._last_response_received_time 
                                + _ALLOWANCE_STATE_REFRESH_SECONDS):
          self._get_usage()

Please let us know if there are any other issues with this! If not, this pull request will be closed.

And thank you again for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants