def _updateRegistration(self, fd):
        try:
            fileno = fd.fileno() if not isinstance(fd, int) else fd
            self._poller.unregister(fileno)
        except (SocketError, IOError, ValueError) as e:
            if e.args[0] == EBADF:
                keys = [k for k, v in list(self._map.items()) if v == fd]
                for key in keys:
                    del self._map[key]

        mask = 0

        if fd in self._read:
            mask = mask | select.EPOLLIN
        if fd in self._write:
            mask = mask | select.EPOLLOUT

        if mask:
            self._poller.register(fd, mask)
            self._map[fileno] = fd
        else:
            super(EPoll, self).discard(fd)
dataset/ETHPy150Open circuits/circuits/circuits/core/pollers.py/EPoll._updateRegistration/original