Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Burnin script shell execution #646

Merged
merged 2 commits into from
Jun 13, 2024
Merged

Conversation

iLLiCiTiT
Copy link
Member

Changelog Description

Try to auto-fix usage of shell=True in burnin script.

Additional info

In some cases the shell set to True might cause that the subprocess don't have access to the executable. Ideal case would be to not use shell=True at all, that would require more modifications. To avoid it we can run "testing" ffmpeg command and change it to False if it crashes.

@iLLiCiTiT iLLiCiTiT requested a review from kalisp June 12, 2024 17:05
@ynbot ynbot added size/XS type: bug Something isn't working labels Jun 12, 2024
Copy link
Member

@kalisp kalisp left a comment

Choose a reason for hiding this comment

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

Works at client site.

@kalisp kalisp assigned iLLiCiTiT and unassigned kalisp Jun 12, 2024
Comment on lines +486 to +498
use_shell = True
try:
test_proc = subprocess.Popen(
f"{FFMPEG_EXE_COMMAND} --help", shell=True
)
test_proc.wait()
except BaseException:
use_shell = False

kwargs = {
"stdout": subprocess.PIPE,
"stderr": subprocess.PIPE,
"shell": True,
"shell": use_shell,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't these subprocess calls technically mean they may show up a command prompt dialog on Windows? Shouldn't these have that "hide console window" special flag?

Also, it's really annoying we have to do this because these subprocess calls startup always take longer than I'd like. I mean it's better than failing.

Maybe we could cache the "should we run in shell" result for the running process? (Does that even make sense since this would be a script that would maybe already itself be running in a subprocess maybe?)

Copy link
Member Author

@iLLiCiTiT iLLiCiTiT Jun 12, 2024

Choose a reason for hiding this comment

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

Also, it's really annoying we have to do this because these subprocess calls startup always take longer than I'd like. I mean it's better than failing.

Maybe we could cache the "should we run in shell" result for the running process? (Does that even make sense since this would be a script that would maybe already itself be running in a subprocess maybe?)

This is called only once during the process lifetime (single extract burning process).

Ideal fix is to rewrite the logic so output is list of arguments, in that case we can get rid of shell=True (lack of time and patience).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup - thanks for confirming.

@iLLiCiTiT iLLiCiTiT merged commit 3d0a35d into develop Jun 13, 2024
1 check passed
@iLLiCiTiT iLLiCiTiT deleted the bugfix/burnin-script-shell branch June 13, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS type: bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants