summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-05-30 11:30:32 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2012-05-30 11:30:32 (GMT)
commit949d8c986ec8792fbe63d8bd2bb5332406c5af9a (patch)
tree192ad8ee5138f23b37b295272c245f568bf0d9b8 /Lib/subprocess.py
parent5e92a1ef5a906cd34f122cf0ee54e0303ae07a5f (diff)
downloadcpython-949d8c986ec8792fbe63d8bd2bb5332406c5af9a.zip
cpython-949d8c986ec8792fbe63d8bd2bb5332406c5af9a.tar.gz
cpython-949d8c986ec8792fbe63d8bd2bb5332406c5af9a.tar.bz2
Close #14690: Use monotonic clock instead of system clock in the sched,
subprocess and trace modules.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 553f160..7885ba3 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -349,6 +349,10 @@ import signal
import builtins
import warnings
import errno
+try:
+ from time import monotonic as _time
+except ImportError:
+ from time import time as _time
# Exception classes used by this module.
class SubprocessError(Exception): pass
@@ -894,7 +898,7 @@ class Popen(object):
self.wait()
else:
if timeout is not None:
- endtime = time.time() + timeout
+ endtime = _time() + timeout
else:
endtime = None
@@ -917,14 +921,14 @@ class Popen(object):
if endtime is None:
return None
else:
- return endtime - time.time()
+ return endtime - _time()
def _check_timeout(self, endtime, orig_timeout):
"""Convenience for checking if a timeout has expired."""
if endtime is None:
return
- if time.time() > endtime:
+ if _time() > endtime:
raise TimeoutExpired(self.args, orig_timeout)
@@ -1471,7 +1475,7 @@ class Popen(object):
# printing.
if endtime is not None or timeout is not None:
if endtime is None:
- endtime = time.time() + timeout
+ endtime = _time() + timeout
elif timeout is None:
timeout = self._remaining_time(endtime)