Skip to content

Commit

Permalink
Merge #441
Browse files Browse the repository at this point in the history
441: Remove use of time.clock under Python 3.3+ r=MatthieuDartiailh a=MatthieuDartiailh

Instead we use perf_counter.

Closes #394

Co-authored-by: MatthieuDartiailh <marul@laposte.net>
  • Loading branch information
bors[bot] and MatthieuDartiailh committed Jul 18, 2019
2 parents db85a9d + e64504c commit d13ef76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PyVISA Changelog
1.10 (unreleased)
-----------------

- replace time.clock by time.perf_counter under Python 3 PR #441
- make the ordering of the visa library deterministic PR #399
- properly close pipes when looking for a shared libary path on linux #380
- fixing missing argument for USBInstrument.usb_control_out PR #353
Expand Down
12 changes: 10 additions & 2 deletions pyvisa/resources/gpib.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
from __future__ import division, unicode_literals, print_function, absolute_import

import time
import sys

if sys.version_info > (3,2):
perf_counter = time.perf_counter
else:
perf_counter = time.clock

from .. import constants
from .resource import Resource
Expand Down Expand Up @@ -98,13 +104,15 @@ def wait_for_srq(self, timeout=25000):
if timeout and not(0 <= timeout <= 4294967295):
raise ValueError("timeout value is invalid")

starting_time = time.clock()
starting_time = perf_counter()

while True:
if timeout is None:
adjusted_timeout = constants.VI_TMO_INFINITE
else:
adjusted_timeout = int((starting_time + timeout/1e3 - time.clock())*1e3)
adjusted_timeout = int((starting_time +
timeout/1e3 -
perf_counter())*1e3)
if adjusted_timeout < 0:
adjusted_timeout = 0

Expand Down

0 comments on commit d13ef76

Please sign in to comment.