Message205162
>>> 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". |
|
Date |
User |
Action |
Args |
2013-12-03 22:24:36 | vstinner | set | recipients:
+ vstinner, gvanrossum, neologix, docs@python |
2013-12-03 22:24:36 | vstinner | set | messageid: <1386109476.76.0.81750681113.issue19876@psf.upfronthosting.co.za> |
2013-12-03 22:24:36 | vstinner | link | issue19876 messages |
2013-12-03 22:24:36 | vstinner | create | |
|