Merge branch 'feature/UpdateProfileHooks' into develop

This commit is contained in:
JackDandy 2018-09-09 17:40:35 +01:00
commit f97459d6ce
2 changed files with 13 additions and 8 deletions

View file

@ -5,6 +5,7 @@
* Update Certifi 2018.01.18 (e225253) to 2018.08.24 (8be9f89)
* Update dateutil module 2.7.2 (ff03c0f) to 2.7.2 (49690ee)
* Update feedparser 5.2.1 (5646f4c) to 5.2.1 (2b11c80)
* Update profilehooks module 1.10.0 (0ce1e29) to 1.10.1 (fdbf19d)
[develop changelog]

View file

@ -104,7 +104,7 @@ Released under the MIT licence since December 2006:
__author__ = "Marius Gedminas <marius@gedmin.as>"
__copyright__ = "Copyright 2004-2017 Marius Gedminas and contributors"
__license__ = "MIT"
__version__ = '1.10.0'
__version__ = '1.10.1.dev0'
__date__ = "2017-12-09"
@ -319,7 +319,7 @@ class FuncProfile(object):
self.fn = fn
self.skip = skip
self.filename = filename
self.immediate = immediate
self._immediate = immediate
self.stdout = stdout
self.dirs = dirs
self.sort = sort or ('cumulative', 'time', 'calls')
@ -327,8 +327,13 @@ class FuncProfile(object):
self.sort = (self.sort, )
self.entries = entries
self.reset_stats()
if not self.immediate:
atexit.register(self.atexit)
@property
def immediate(self):
return self._immediate
def __call__(self, *args, **kw):
"""Profile a singe call to the function."""
self.ncalls += 1
@ -387,8 +392,6 @@ class FuncProfile(object):
This function is registered as an atexit hook.
"""
# XXX: uh, why even register this as an atexit hook if immediate is True?
if not self.immediate:
self.print_stats()
@ -650,7 +653,8 @@ class FuncSource:
strs = set()
prev = token.INDENT # so module docstring is detected as docstring
with open(filename) as f:
for ttype, tstr, start, end, line in tokenize.generate_tokens(f.readline):
tokens = tokenize.generate_tokens(f.readline)
for ttype, tstr, start, end, line in tokens:
if ttype == token.STRING and prev == token.INDENT:
strs.update(range(start[0], end[0] + 1))
prev = ttype
@ -757,8 +761,8 @@ class FuncTimer(object):
fn = self.fn
timer = self.timer
self.ncalls += 1
try:
start = timer()
try:
return fn(*args, **kw)
finally:
duration = timer() - start