Skip to content

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