Python: execute a long script without block the main process
<p>I'm using GNU/Linux and python 2.7.3, I'm new on it. I'm trying to execute a long installed system process like <code>ffmpeg</code> using the <code>Popen()</code> command to avoid blocking the main python process. I can't make it work.</p>

<p>My first attempt was to use threads, but it is a bit complicated, because the graphical interface doesn't work properly (and I suppose there has to be a better way) </p>

<p>Then I tried fork, but it is like killing flies with tanks.</p>

<p>Now I'm trying to use <code>Popen</code>, I saw a lot of references to its use in the internet, but I'm not running it properly I think. Maybe I'm misunderstanding the examples.</p>

<p>I've tried: </p>

<pre><code>##command is ffmpeg like that works ok
p = subprocess.Popen(command, shell=True)    
</code></pre>

<p>I've tried also:</p>

<pre><code>p = subprocess.Popen(command,stdin=PIPE, shell=True)
</code></pre>

<p>Usually I get an error or a sequentcial behavior, the command ends and then the main program resumes. What am I missing? </p>

<p>The command part:</p>

<pre><code>    global vidSource
    global srtSource
    global done
    size = "3"

    font = "/usr/share/fonts/truetype/freefont/FreeSerif.ttf"
    command = 'mencoder ' + '"' + vidSource + '"' + " -oac copy -ovc lavc -lavdopts threads=2 -sub " + "'" + srtSource + "'" + " -subcp -utf8 -font "+ '"'+ font+ '"' + " -subfont-text-scale " + size + " -o " + '"' + vidSource + '2'+'"' 
</code></pre>
