Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Open
zariuq wants to merge 1 commit into
RandomOrg:masterRandomOrg/JSON-RPC-Python:masterfrom
zariuq:masterzariuq/JSON-RPC-Python:masterCopy head branch name to clipboard
Open

time.clock() -> time.process_time()#9
zariuq wants to merge 1 commit into
RandomOrg:masterRandomOrg/JSON-RPC-Python:masterfrom
zariuq:masterzariuq/JSON-RPC-Python:masterCopy head branch name to clipboard

Conversation

@zariuq

@zariuq zariuq commented Jul 5, 2022

Copy link
Copy Markdown

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

@RandomOrgDev

Copy link
Copy Markdown
Collaborator

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.