STINNER Victor added the comment: >>> import selectors, os >>> r,w=os.pipe() >>> s=selectors.SelectSelector() >>> s.register(r, selectors.EVENT_READ) SelectorKey(fileobj=3, fd=3, events=1, data=None) >>> os.close(r) >>> os.close(w) >>> s.unregister(r) SelectorKey(fileobj=3, fd=3, events=1, data=None)
SelectSelector.unregister(<closed fd>) doesn't raise any error, so it makes sense to ignore EBADF in EpollSelector.unregister(). What's the point of raising an error here? If you want a portable behaviour, the file descriptor should be tested (ex: call os.fstat or os.dup). For the "normal" use case, I would not expect a syscall on unregister(), because unregister() may be called just before closing the file descriptor. Maybe you can explain that in the "caveats" section? Suggestion: "unregister(fd) does not check if fd is closed or not (to get a portable behaviour), os.fstat() or os.dup() can be used to check if the fd is closed or not". Or "unregister(fd) ignores error if the file descriptor is closed". ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19876> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com