Hi:<br><br>Aren&#39;t you adding two readers?  One is added in the __init__ method of inputFile, the other in the test code.<br><br>I&#39;m also a newbie so maybe I&#39;m equally confused...<br><br><div class="gmail_quote">
On Tue, Feb 9, 2010 at 8:47 PM, K. Richard Pixley <span dir="ltr">&lt;<a href="mailto:rich@noir.com">rich@noir.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;">




<div bgcolor="#ffffff" text="#000000">
I&#39;m confused be the response I get to the attached program.<br>
<br>
In a nutshell, I&#39;m building a reader, attaching it with addReader,
later removing it with removeReader.  And I&#39;m getting this:<br>
<blockquote><tt>time python test_reactor.py</tt><br>
  <tt>Traceback (most recent call last):</tt><br>
  <tt>Failure: twisted.internet.error.ConnectionFdescWentAway: Uh:
Filedescriptor went away.</tt><br>
</blockquote>
Which seems to be telling me that I don&#39;t know as much yet as I&#39;d hoped.<br>
<br>
Why would the reactor care about a closed file descriptor that isn&#39;t
even in it&#39;s interest set?<br>
<br>
--rich<br>
</div>

<br>#!/usr/bin/env python<br>
# -*- coding: utf-8 -*-<br>
<br>
import os<br>
<br>
from zope.interface import implements<br>
from twisted.internet import reactor<br>
from twisted.internet.interfaces import IReadDescriptor<br>
<br>
class inputFile(object):<br>
    implements(IReadDescriptor)<br>
<br>
    def __init__(self, filename):<br>
        self.filename = filename<br>
        self.filedes = os.open(filename, os.O_RDONLY | os.O_NONBLOCK)<br>
        reactor.addReader(self)<br>
<br>
    def fileno(self):<br>
        return self.filedes<br>
<br>
    def connectionLost(self, reason):<br>
        raise reason<br>
<br>
    def logPrefix(self):<br>
        return &#39;inputFile&#39;<br>
<br>
    def doRead(self):<br>
        reactor.removeReader(self)<br>
        os.close(self.filedes)<br>
        self.filedes = -1<br>
        reactor.stop()<br>
<br>
if __name__ == &#39;__main__&#39;:<br>
    r = inputFile(&#39;/etc/group&#39;)<br>
    reactor.addReader(r)<br>
    reactor.run()<br>
<br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div><br>