Skip to content

Add an "unbuffered" argument to shell functions#33

Open
javierggt wants to merge 1 commit intomasterfrom
unbuffered
Open

Add an "unbuffered" argument to shell functions#33
javierggt wants to merge 1 commit intomasterfrom
unbuffered

Conversation

@javierggt
Copy link
Copy Markdown
Contributor

@javierggt javierggt commented Apr 23, 2026

Description

Add an "unbuffered" argument to shell functions, which causes the output to be logged as it arrives instead of all at the end.

Some of the changes I had in the runasp repo were actually not specific to the aspect pipeline. They were changes to be able to see output in real time (to check things were working right away). Instead of making them there, better to make them here.

Interface impacts

Testing

Unit tests

Unit tests include new tests for the new feature (3 tests parametrized by 2, 6 new tests total).

  • Mac
  • Linux
jgonzale ska_shell $ git rev-parse HEAD
a96d9e519590660e208111ca0b3b478612cf144b
jgonzale ska_shell $ pytest ska_shell
========================================================================================= test session starts =========================================================================================
platform linux -- Python 3.13.11, pytest-9.0.2, pluggy-1.6.0
rootdir: /proj/sot/ska/jgonzalez/git
configfile: pytest.ini
plugins: anyio-4.12.1, timeout-2.4.0
collected 30 items                                                                                                                                                                                    

ska_shell/tests/test_shell.py ..............................                                                                                                                                    [100%]

========================================================================================= 30 passed in 3.83s ==========================================================================================

Independent check of unit tests by Jean

  • linux
jeanconn-kady> pytest
============================= test session starts ==============================
platform linux -- Python 3.13.11, pytest-9.0.2, pluggy-1.6.0
rootdir: /proj/sot/ska/jeanproj/git
configfile: pytest.ini
plugins: anyio-4.12.1, timeout-2.4.0
collected 30 items                                                             

ska_shell/tests/test_shell.py ..............................             [100%]

============================== 30 passed in 4.58s ==============================
jeanconn-kady> git rev-parse HEAD
a96d9e519590660e208111ca0b3b478612cf144b

Functional tests

Tests are covered in unit tests, but if you want to see it in action, run this in one terminal while you tail -f test.log on another terminal:

import ska_shell

cmd = """echo 1
sleep 1
echo 2
sleep 1
echo 3
sleep 1
echo 4
sleep 1
echo 5
sleep 1
echo 6
sleep 1
echo 7
"""
with open("test.log", "w") as fh:
    ska_shell.tcsh_shell(cmd, logfile=fh, unbuffered=True)

…put to be logged as it arrives instead of all at the end.
@javierggt javierggt requested a review from jeanconn April 23, 2026 16:32
Copy link
Copy Markdown
Contributor

@jeanconn jeanconn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants