Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mock
isort
black
flake8
mypy<2.0.0
mypy

# Distribution
setuptools; python_version >= "3.12"
Expand Down
6 changes: 4 additions & 2 deletions time_execution/timed.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def enter(self) -> Any:
self._start_time = default_timer()
for hook in self._hooks:
if isgenerator(hook):
hook.send(None) # start a generator hook
gen = cast(GeneratorHookReturnType, hook)
next(gen) # advance to the first yield
return self

def get_metric(self) -> Dict[str, Any]:
Expand Down Expand Up @@ -94,8 +95,9 @@ def apply_hook(
)
else:
# Generator hook: send the results and obtain custom metadata.
gen = cast(GeneratorHookReturnType, hook)
try:
hook.send((self.result, exception, metric))
gen.send((self.result, exception, metric))
except StopIteration as e:
hook_result = e.value
else:
Expand Down
Loading