2016-04-01 17:38 GMT+01:00 Naoki INADA <[email protected]>:
>
> EPOLLEXCLUSIVE is usuful in multi process (prefork) servers too.
> uWSGI supports both of prefork and thread, but I tested in single thread
> mode (pure prefork).

Yes, I thought about cases where FDs are shared through fork, but I didn't
think anyone was using selectors in such settings.
I'm glad it's actually used :-)

Maybe:

Maybe:

abstractmethod register(fileobj, events, data=None, **flags)
...
poller.register(listenfd, selectors.EVENT_READ, data, exclusive=True)  #
only EpollSelector supports exclusive. others ignore unknown flags.


Or:

poller.register(listenfd, selectors.EVENT_READ_EXCLUSIVE, data)   # Add
EVENT_READ_EXCLUSIVE and EVENT_READ_EXCLUSIVE.


I don't really like the second option, because even when a FD is registered
with EPOLLEXCLUSIVE, it's still intrinsically just a read/write event.
Also, this leads to combinatorial explosion if we want to support more
flags beyond EPOLLEXCLUSIVE, for example EPOLLROUNDROBIN if it ever gets
merged.

Maybe we could have a enum of specifig flags,

e.g.

class PollFlag(Enum):
    exclusive    = 0
    round_robin = 1

And then allow passing a set of flags to register, so something like:

abstractmethod register(fileobj, events, data=None, flags=None)
...
poller.register(listenfd, selectors.EVENT_READ, data, {PollFlag.exclusive})
  # only EpollSelector supports exclusive. others ignore unknown flags.


This will avoid polluting the API with a potentially unbounded number of
optional arguments (so users which don't need them won't wonder about them).

Reply via email to