Skip to content

Commit

Permalink
Merge 33d7ec2 into cde4bee
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiirola committed Nov 7, 2019
2 parents cde4bee + 33d7ec2 commit c87f211
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 29 deletions.
5 changes: 4 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
- PYTHON: "C:\\Miniconda-x64"
#PYTHON: "C:\\Python27"

#- PYTHON: "C:\\Miniconda3-x64"
#- PYTHON: "C:\\Miniconda34-x64"
# #PYTHON: "C:\\Python34"

- PYTHON: "C:\\Miniconda35-x64"
Expand All @@ -19,6 +19,9 @@ environment:
- PYTHON: "C:\\Miniconda36-x64"
#PYTHON: "C:\\Python36"

- PYTHON: "C:\\Miniconda37-x64"
#PYTHON: "C:\\Python37"

#- PYTHON: "C:\\Python27-x64"
#- PYTHON: "C:\\Python33-x64"
# DISTUTILS_USE_SDK: "1"
Expand Down
28 changes: 16 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ matrix:
include:
- python: '2.7'
env: PYRO="Pyro" YAML="pyyaml"
#- python: '2.7'
# env: PYRO="Pyro" JYTHON="org.python:jython-installer:2.7.0"
- python: '3.4'
env: PYRO="Pyro4" YAML="pyyaml"
- python: '3.5'
env: PYRO="Pyro4" YAML="pyyaml"
- python: '3.6'
#- python: '2.7'
# env: PYRO="Pyro" JYTHON="org.python:jython-installer:2.7.0"
- python: '3.4'
env: PYRO="Pyro4" YAML="pyyaml"
- python: '3.6'
- python: '3.5'
env: PYRO="Pyro4" YAML="pyyaml"
- python: '3.6'
env: PYRO="Pyro4" YAML="pyyaml"
- python: '3.7'
env: PYRO="Pyro4" YAML="pyyaml"
- python: '3.8'
env: PYRO="Pyro4" YAML="pyyaml"
- python: '3.6'
env: PYRO="Pyro4" YAML=""
- python: pypy
env: PYRO="Pyro" YAML="pyyaml"
- python: pypy3
env: PYRO="Pyro4" YAML="pyyaml"
- python: pypy
env: PYRO="Pyro" YAML="pyyaml"
- python: pypy3
env: PYRO="Pyro4" YAML="pyyaml"
install:
- if [ -n "${JYTHON}" ]; then source install_jython.sh; fi
- if [ -n "${YAML}" ]; then pip install pyyaml; fi
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 23 additions & 6 deletions pyutilib/misc/timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@

__all__ = ('TicTocTimer', 'tic', 'toc')

#
# Setup the timer
#
if sys.version_info >= (3,3):
# perf_counter is guaranteed to be monotonic and the most accurate timer
_time_source = time.perf_counter
else:
# On old Pythons, clock() is more accurate than time() on Windows
# (.35us vs 15ms), but time() is more accurate than clock() on Linux
# (1ns vs 1us). It is unfortunate that time() is not monotonic, but
# since the TicTocTimer is used for (potentially very accurate)
# timers, we will sacrifice monotonicity on Linux for resolution.
if sys.platform.startswith('win'):
_time_source = time.clock
else:
_time_source = time.time

class TicTocTimer(object):
"""A class to calculate and report elapsed time.
Expand All @@ -33,7 +50,7 @@ class TicTocTimer(object):
logging package. Note: timing logged using logger.info
"""
def __init__(self, ostream=None, logger=None):
self._lastTime = self._loadTime = time.time()
self._lastTime = self._loadTime = _time_source()
self._ostream = ostream
self._logger = logger
self._start_count = 0
Expand All @@ -56,7 +73,7 @@ def tic(self, msg=None, ostream=None, logger=None):
logging package (overrides the ostream provided when the
class was constructed). Note: timing logged using logger.info
"""
self._lastTime = time.time()
self._lastTime = _time_source()
if msg is None:
msg = "Resetting the tic/toc delta timer"
if msg:
Expand Down Expand Up @@ -90,11 +107,11 @@ class was constructed). Note: timing logged using logger.info
msg = 'File "%s", line %s in %s' % \
traceback.extract_stack(limit=2)[0][:3]

now = time.time()
now = _time_source()
if self._start_count or self._lastTime is None:
ans = self._cumul
if self._lastTime:
ans += time.time() - self._lastTime
ans += _time_source() - self._lastTime
if msg:
msg = "[%8.2f|%4d] %s\n" % (ans, self._start_count, msg)
elif delta:
Expand Down Expand Up @@ -124,7 +141,7 @@ class was constructed). Note: timing logged using logger.info

def stop(self):
try:
delta = time.time() - self._lastTime
delta = _time_source() - self._lastTime
except TypeError:
if self._lastTime is None:
raise RuntimeError(
Expand All @@ -138,7 +155,7 @@ def start(self):
if self._lastTime:
self.stop()
self._start_count += 1
self._lastTime = time.time()
self._lastTime = _time_source()

_globalTimer = TicTocTimer()
tic = _globalTimer.tic
Expand Down
2 changes: 1 addition & 1 deletion pyutilib/ply/ply.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def p_error(p):
tmp = "Syntax error at end of file."
else:
tmp = "Syntax error at token "
if p.type is "":
if p.type == "":
tmp = tmp + "''"
else:
tmp = tmp + str(p.type)
Expand Down
21 changes: 13 additions & 8 deletions pyutilib/subprocess/processmngr.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ def bytes_cast(x):
else:
bytes_cast = lambda x: x # Do nothing

#
# Setup the timer
#
if sys.version_info >= (3,3):
# perf_counter is guaranteed to be monotonic and the most accurate timer
timer = time.perf_counter
else:
# On old Pythons, clock() is more accurate than time() on Windows
# (.35us vs 15ms), but time() is more accurate than clock() on Linux
# (1ns vs 1us). However, since we are only worring about process
# timeouts here, we will stick with strictly monotonic timers
timer = time.clock


def kill_process(process, sig=signal.SIGTERM, verbose=False):
"""
Expand Down Expand Up @@ -718,14 +731,6 @@ def run_command(cmd,
# Create an alias for run_command
run = run_command

#
# Setup the timer
#
if _mswindows:
timer = time.clock
else:
timer = time.time


class SubprocessMngr(object):

Expand Down
2 changes: 1 addition & 1 deletion pyutilib/workflow/functor.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def __init__(self, *args, **kwargs):
kwargs['fn'] = fn
FunctorTask.__init__(self, *args, **kwargs)
if not fn is None:
if len(argspec.args) is 0:
if len(argspec.args) == 0:
nargs = 0
elif argspec.defaults is None:
nargs = len(argspec.args)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def read(*rnames):
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: Jython',
'Programming Language :: Python :: Implementation :: PyPy',
Expand Down

0 comments on commit c87f211

Please sign in to comment.