[issue18932] Optimize selectors.EpollSelector.modify()

STINNER Victor report at bugs.python.org
Thu Feb 5 10:07:34 CET 2015


STINNER Victor added the comment:

> - drop SelectSelector._modify(): calling unregister() + register() is just fine

I checked with strace: PollSelector.modify() doesn't require any syscall, so I propose to also drop it (to just call unregister + register). What do you think?

I would like to reduce the number of syscalls, calling a C function of the glibc is cheap.

> This is a follow up of issue 16853 (see comment http://bugs.python.org/issue16853#msg196984).

"(...) the problem with unregister() + register() vs a real
modify (e.g. EPOLL_CTL_MOD) is that it's subject to a race condition,
if an event fires during the short window where the FD isn't
registered anymore."

The race condition only occurs with selectors which have a state machine in the kernel: epoll, kqueue, devpoll. SelectSelector and PollSelector are state-less (in the kernel, the state is build for a single syscall and then destroyed). Am I right?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18932>
_______________________________________


More information about the Python-bugs-list mailing list