Skip to content

Commit

Permalink
fix: correct execution time for multiple cells (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlubas committed May 10, 2024
1 parent 7f1c31d commit ab9351b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rplugin/python3/molten/outputbuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _get_header_text(self, output: Output) -> str:
else:
old = ""

if not output.old and self.options.output_show_exec_time:
if not output.old and self.options.output_show_exec_time and output.start_time:
start = output.start_time
end = output.end_time if output.end_time is not None else datetime.now()
diff = end - start
Expand Down
6 changes: 3 additions & 3 deletions rplugin/python3/molten/outputchunks.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ class Output:
status: OutputStatus
success: bool
old: bool
start_time: datetime
end_time: datetime
start_time: datetime | None
end_time: datetime | None

_should_clear: bool

Expand All @@ -191,7 +191,7 @@ def __init__(self, execution_count: Optional[int]):
self.success = True
self.old = False

self.start_time = datetime.now()
self.start_time = None
self.end_time = None

self._should_clear = False
Expand Down
2 changes: 2 additions & 0 deletions rplugin/python3/molten/runtime.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from typing import Optional, Tuple, List, Dict, Generator, IO, Any
from enum import Enum
from contextlib import contextmanager
Expand Down Expand Up @@ -142,6 +143,7 @@ def copy_on_demand(content_ctor):
return False
if output.status == OutputStatus.HOLD:
output.status = OutputStatus.RUNNING
output.start_time = datetime.now()
elif output.status == OutputStatus.RUNNING:
output.status = OutputStatus.DONE
else:
Expand Down

0 comments on commit ab9351b

Please sign in to comment.