Author gvanrossum
Recipients docs@python, gvanrossum, neologix, vstinner
Date 2013-12-03.22:45:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1386110732.13.0.93557427052.issue19876@psf.upfronthosting.co.za>
In-reply-to
Content
Heh, I'd forgotten the behavior of unregister().  It seems that there are two layers to the behavior -- if this FD was never register()ed it will raise; if it was register()ed but has since been close()d it may raise.

For the higher-level APIs in asyncio I chose not to raise from the remove_{reader,writer}() methods -- they return True if something was removed, False if not.  This currently has to be implemented by explicitly asking the selector for the key first.  I.e.:

    def remove_reader(self, fd):
        """Remove a reader callback."""
        try:
            key = self._selector.get_key(fd)
        except KeyError:
            return False
        else:
            mask, (reader, writer) = key.events, key.data
            mask &= ~selectors.EVENT_READ
            if not mask:
                self._selector.unregister(fd)
            else:
                self._selector.modify(fd, mask, (None, writer))

            if reader is not None:
                reader.cancel()
                return True
            else:
                return False
History
Date User Action Args
2013-12-03 22:45:32gvanrossumsetrecipients: + gvanrossum, vstinner, neologix, docs@python
2013-12-03 22:45:32gvanrossumsetmessageid: <1386110732.13.0.93557427052.issue19876@psf.upfronthosting.co.za>
2013-12-03 22:45:32gvanrossumlinkissue19876 messages
2013-12-03 22:45:31gvanrossumcreate