Skip to content

Commit

Permalink
Merge pull request #222 from berleon/fix-captured-func
Browse files Browse the repository at this point in the history
Allow captured functions to be called normal code
  • Loading branch information
Qwlouse committed Oct 31, 2017
2 parents d08bbe9 + b75bf10 commit c739726
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sacred/config/captured_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ def captured_function(wrapped, instance, args, kwargs):
bound = (instance is not None)
args, kwargs = wrapped.signature.construct_arguments(args, kwargs, options,
bound)
wrapped.logger.debug("Started")
start_time = time.time()
if wrapped.logger is not None:
wrapped.logger.debug("Started")
start_time = time.time()
# =================== run actual function =================================
result = wrapped(*args, **kwargs)
# =========================================================================
stop_time = time.time()
elapsed_time = timedelta(seconds=round(stop_time - start_time))
wrapped.logger.debug("Finished after %s.", elapsed_time)
if wrapped.logger is not None:
stop_time = time.time()
elapsed_time = timedelta(seconds=round(stop_time - start_time))
wrapped.logger.debug("Finished after %s.", elapsed_time)

return result

0 comments on commit c739726

Please sign in to comment.