Skip to content

Commit 6aba714

Browse files
committed
refactor: streaming/printer internals to be less confusing
1 parent 20ff236 commit 6aba714

14 files changed

Lines changed: 745 additions & 800 deletions

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dev = [
3535
"mypy>=1.7.0,<2",
3636
"pyinstaller==6.11.0",
3737
"ruff>=0.15.20",
38+
"debugpy>=1.8.21",
3839
]
3940

4041
[build-system]

‎src/pyallel/constants.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def lines() -> int:
3535

3636
ICONS = ("/", "-", "\\", "|")
3737

38+
# The maximum time to wait between renders in seconds
39+
MAX_WAIT_BETWEEN_RENDERS = 0.1
40+
3841
# Unicode character bytes to render different symbols in the terminal
3942
TICK = "\u2714"
4043
X = "\u2718"

‎src/pyallel/main.py‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ def entry_point(*args: str) -> int:
6464

6565
if exit_code == 1:
6666
logger.error("failed run with arguments:\n%s", parsed_args)
67-
process_group = process_group_manager.get_cur_process_group_output()
67+
process_group = process_group_manager.cur_process_group
6868
print(f"\n{colours.red_bold}ERROR: the following commands failed{colours.reset_colour}")
69-
for process_output in process_group.processes:
70-
process_poll = process_output.process.poll()
69+
for process in process_group.processes:
70+
process_poll = process.poll()
7171
if process_poll and process_poll > 0:
72-
print(f" {colours.red_bold}{process_output.process.command}{colours.reset_colour}")
72+
print(f" {colours.red_bold}{process.command}{colours.reset_colour}")
7373
else:
7474
logger.debug("finished run with arguments:\n%s", parsed_args)
7575

@@ -79,15 +79,15 @@ def entry_point(*args: str) -> int:
7979
def run(process_group_manager: ProcessGroupManager, printer: Printer) -> int:
8080
process_group_manager.run()
8181
while True:
82-
process_group_manager.stream()
83-
printer.print(process_group_manager)
82+
output = process_group_manager.stream()
83+
printer.print(output)
8484

8585
poll = process_group_manager.poll()
8686
if poll is not None:
87-
# If we still have new output to print after the process group manager has completed,
87+
# If we still have new output to print after the process group has completed,
8888
# make sure to print it here before continuing
89-
if process_group_manager.stream().has_output():
90-
printer.print(process_group_manager)
89+
output = process_group_manager.stream()
90+
printer.print(output, done=True)
9191

9292
if poll > 0:
9393
return poll
@@ -96,7 +96,7 @@ def run(process_group_manager: ProcessGroupManager, printer: Printer) -> int:
9696
if not process_group_manager.next():
9797
return 0
9898

99-
time.sleep(0.1)
99+
time.sleep(0.01)
100100

101101

102102
if __name__ == "__main__":

0 commit comments

Comments
 (0)