title: Python - OSError 24 (Too many open files) and shared memory
body: <p>I faced with the problem there was exception OSError 24 ("Too many open files") raised on my mac os x in python script.</p>
  
  <p>I had no idea what could caused that issue. lsof -p showed about 40-50 lines, and my ulimit was 1200 (I check that using</p>
  
  <pre><code>resource.getrlimit(resource.RLIMIT_NOFILE)
  </code></pre>
  
  <p>), that returned tuple (1200, 1200). So I didn't exceed limit even closely.</p>
  
  <p>That my script spawned number of subprocesses and also allocated shared memory segments. Exception occurred while allocating shared memory segments. I use <a href="http://semanchuk.com/philip/sysv_ipc/" rel="nofollow">sysv_ipc module</a>.</p>
  
  <p>Also I knew I total allowed number of shared memory segments is enough large (128 segments), and command</p>
  
  <pre><code>ipcs -b -m
  </code></pre>
  
  <p>gave definitely less number (not more then 40 segments).</p>