commands.getoutput() raises Errno 12 - Cannot allocate memory
<p>I have a Python script which runs on a server with RHEL5. The server has 32GB memory and 8 Intel Xeon CPUs at 2.83GHz. I think the hardware resource should not be a problem, but when I attempt to upload and process a 15 million line text file, the program gives me an error message:</p>

<pre><code>Traceback (most recent call last):
  File "./test.py", line 511, in &lt;module&gt;
    startup()
  File "./test.py", line 249, in startup
    cmdoutput = commands.getoutput(cmd_file)
  File "/usr/local/lib/python2.6/commands.py", line 46, in getoutput
    return getstatusoutput(cmd)[1]
  File "/usr/local/lib/python2.6/commands.py", line 55, in getstatusoutput
    pipe = os.popen('{ ' + cmd + '; } 2&gt;&amp;1', 'r')
OSError: [Errno 12] Cannot allocate memory
</code></pre>

<p>I have investigated this problem and did not found any answers that exactly match my problem. Those answers were focused on the "popen" subroutine, but I do not use this routine. I just use the "<code>commands.getoutput()</code>" to display the file type of a document.</p>

<p>It should be noted that if I try to process a 10 million line text, this problem does not happen. It only happens when the text file is large.
Can any people help me out on this issue? The answer could be a better module other than the "<code>command.getoutput()</code>". Thanks!</p>
