Skip to content

console breaks when running in parallel #108

@kylemcdonald

Description

@kylemcdonald

I am calling the following code inside the job of an pool.imap_unordered:

    data, _ = (ffmpeg
               .input(filename)
               .output('pipe:', format=format, acodec=acodec, ac=ac, ar=sr)
               .run(capture_stdout=True, capture_stderr=True))

in order to load a lot of audio in parallel. It seems to work correctly, but when it's done running I can't type in the console anymore. Or rather, the text I type does not appear, but when I hit return the commands are still executed.

If I run the script inside screen and then exit the screen, the original console works.

Is there another way that I should be running ffmpeg-python when using multiprocessing?

Looking at this issue https://askubuntu.com/questions/171449/shell-does-not-show-typed-in-commands-reset-works-but-what-happened my situation matches it very closely. Before I run the script the result of stty --all is:

speed 9600 baud; rows 33; columns 197; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O;
min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

and after it is:

speed 9600 baud; rows 33; columns 197; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O;
min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

echo is one of the options that switches from true to false. But I can't find what in the ffmpeg-python library causes this.

Previously I had written my own wrapper to ffmpeg https://github.com/kylemcdonald/python-utils/blob/master/ffmpeg_load_audio.py I didn't notice this problem before. But I just did some more testing and it has the same bug. Which means it's something pretty basic about running Popen in threads.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions