'Close both ends of my pipe.'

def connectionLost(self, reason):

    if (not hasattr(self, 'o')):
        return
    for fd in (self.i, self.o):
        try:
            os.close(fd)
        except IOError:
            pass
    del self.i, self.o
