Skip to content

Conversation

glehmann
Copy link
Member

@glehmann glehmann commented Aug 6, 2025

os.system calls the user's shell, and is not directly checking for errors. This should raise an error when cpio or rpm2cpio fail, or if they can't be found.

@glehmann glehmann requested a review from stormi August 6, 2025 12:11
@glehmann glehmann force-pushed the gln/srpm-error-handling-wlnl branch from a1f7b08 to 3782f97 Compare August 6, 2025 14:42
@stormi stormi requested a review from tperard August 6, 2025 14:45
@glehmann glehmann force-pushed the gln/srpm-error-handling-wlnl branch from 3782f97 to 5149284 Compare August 11, 2025 07:54
@glehmann glehmann requested a review from psafont August 12, 2025 06:23
@glehmann glehmann force-pushed the gln/srpm-error-handling-wlnl branch from 5149284 to 2c59a22 Compare August 13, 2025 09:05
raise ValueError("All commands in the list must be non-empty.")

processes: list[subprocess.Popen[bytes]] = []
last_process_stdout = None
Copy link
Contributor

Choose a reason for hiding this comment

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

naming it next_process_stdin would make it more accurate

Copy link
Member Author

@glehmann glehmann Aug 25, 2025

Choose a reason for hiding this comment

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

I suppose it depends on which side of the pipe you're looking at 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

in one way yes, but I'm rather seeing it as "in one case the name is always valid, while in the other there is no previous process when launching the first one"

Copy link
Member Author

Choose a reason for hiding this comment

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

That's why it's a IO[bytes] | None.
But I'm also ok with the other name, I'll use it 👍

Comment on lines 30 to 32
# to prevent deadlocks if the current process finishes before the previous one.
if last_process_stdout:
last_process_stdout.close()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure of the nature of the deadlock, but avoiding keeping 2 readers on the pipe is definitely a good idea. Maybe describe it like "the new process does the reading from this pipe, drop our ref to it, notably preventing deadlocks"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wrote that based on an example I found, but I can't produce any deadlock, and I find plenty of examples that don't use it. I'll remove it.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be kept, as explained (much better) in the API doc

Comment on lines 37 to 40
for i, p in enumerate(processes):
p.wait()
if p.returncode != 0:
raise subprocess.CalledProcessError(returncode=p.returncode, cmd=commands[i])
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe more clear with for cmd, p in zip(commands, processes)?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

os.system calls the user's shell, and is not directly checking for errors.
This should raise an error when cpio or rpm2cpio fail, or if they can't
be found.

Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
@glehmann glehmann force-pushed the gln/srpm-error-handling-wlnl branch from 2c59a22 to fa8bab3 Compare August 25, 2025 15:59
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.

4 participants