Glyph, thanks for the great feedback.  I&#39;m looking into all of this now.  <div><br></div><div>I don&#39;t think it&#39;s a ulimit issue as it seems to be &quot;unlimited&quot;</div><div><br></div><div><div>root@Proxy1:~# ulimit</div>
<div>unlimited</div><div><br></div><div>I think my first step will be to just make a log observer that will simply restart the proxy script when it sees (EMFILE) so that I don&#39;t have to keep logging in at night to restart it myself :).</div>
<div><br></div><div>Thanks for filing that ticket.  It would be great if there were a way to be notified of the particular error inside the code. </div><div><br></div><div><br></div><div>I like your suggestion of keeping a list of my open connections.  I could also keep a time stamp with them and close down the oldest, or any that are over a certain time period.</div>
<div><br></div><div>I&#39;m new to twisted.  Do you know in what object of the Proxy the new connections are made and how to access them to store in a list?    </div><div><br></div><div>Thanks again!</div><div><br></div><div>
Dave Fowler</div><div><br></div><div><br></div><div><br></div><div><br></div></div><div><br><div class="gmail_quote">On Thu, Aug 6, 2009 at 9:31 PM, Glyph Lefkowitz <span dir="ltr">&lt;<a href="mailto:glyph@twistedmatrix.com">glyph@twistedmatrix.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div class="im">On Thu, Aug 6, 2009 at 6:22 PM, dave fowler <span dir="ltr">&lt;<a href="mailto:davefowler@gmail.com" target="_blank">davefowler@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
I guys.  I&#39;m running a twisted web proxy and after a day or so of usage it stops working and start spitting out these errors.<br><br>2009/08/05 14:04 +0000 [__main__.ProxyFactory] Could not accept new connection (EMFILE)<br>




2009/08/05 14:04 +0000 [__main__.ProxyFactory] Could not accept new connection (EMFILE)<br>2009/08/05 14:04 +0000 [__main__.ProxyFactory] Could not accept new connection (EMFILE)<br>2009/08/05 14:04 +0000 [__main__.ProxyFactory] Could not accept new connection (EMFILE)<br>




2009/08/05 14:04 +0000 [__main__.ProxyFactory] Could not accept new connection (EMFILE)<br>2009/08/05 14:04 +0000 [__main__.ProxyFactory] Could not accept new connection (EMFILE)<br><br>Can anyone expand on what this error is or suggestions on fixing it or debugging further?  <br>


<br>What is the EMFILE?  <br></blockquote></div><div><br>It means you&#39;re out of file descriptors for your process.<br><br>See here for the root cause: &lt;<a href="http://linux.die.net/man/2/accept" target="_blank">http://linux.die.net/man/2/accept</a>&gt;,
specifically the part about EMFILE in the Errors section.  I&#39;m actually glad to see this error report - Twisted used to fail in a <i>much</i> worse way in this error condition (&lt;<a href="http://twistedmatrix.com/trac/ticket/662" target="_blank">http://twistedmatrix.com/trac/ticket/662</a>&gt;), this is the first proof I&#39;ve seen that our fix works in the wild :).<br>

<br>To increase your per-process file-descriptor limit, use &quot;ulimit -n&quot;.  Be aware that in order to increase this above 1024, you&#39;ll need to be root; I think there&#39;s a way to set it up to be bigger than that for non-root users but I don&#39;t know how.<br>

<br>In order to free up file descriptors, keep a list of your open connections and shut down some of them.  Sadly, your Factory object won&#39;t be notified of this problem, so you might have to hack something gross together (like a log observer that watches for the string &quot;(EMFILE)&quot;).  I just filed this ticket to provide a nice, clean notification: &lt;<a href="http://twistedmatrix.com/trac/ticket/3958" target="_blank">http://twistedmatrix.com/trac/ticket/3958</a>&gt;.  This may be a duplicate of something, but if so it should be closed with a link to what it&#39;s a duplicate of.<br>

<br>In some cases, connections won&#39;t shut down properly because there is still some buffered data and the other end is not available to acknowledge the connection&#39;s closure.  If this is the case, you can forcibly close the file descriptor (although this may cause some ugliness).  To get a good, supported way to destroy file descriptors in Twisted, see this ticket: &lt;<a href="http://twistedmatrix.com/trac/ticket/78" target="_blank">http://twistedmatrix.com/trac/ticket/78</a>&gt;.<br>

<br>Good luck!  Sorry Twisted has not handled this error in the best way for you, I hope you help us fix some of these bugs for the next guy :).<br><br></div></div>
<br>_______________________________________________<br>
Twisted-web mailing list<br>
<a href="mailto:Twisted-web@twistedmatrix.com">Twisted-web@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
<br></blockquote></div><br></div>