| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -348,15 +348,16 @@ def __init__(self): | |
| super().__init__() | ||
| self._selector = self._selector_cls() | ||
|
|
||
| def register(self, fileobj, events, data=None): | ||
| def register(self, fileobj, events, data=None, register_flags=None): | ||
| key = super().register(fileobj, events, data) | ||
| poller_events = 0 | ||
| if register_flags is None: | ||
| register_flags = 0 | ||
| if events & EVENT_READ: | ||
| poller_events |= self._EVENT_READ | ||
| register_flags |= self._EVENT_READ | ||
| if events & EVENT_WRITE: | ||
| poller_events |= self._EVENT_WRITE | ||
| register_flags |= self._EVENT_WRITE | ||
| try: | ||
| self._selector.register(key.fd, poller_events) | ||
| self._selector.register(key.fd, register_flags) | ||
| except: | ||
| super().unregister(fileobj) | ||
| raise | ||
| Expand Down Expand Up | @@ -445,6 +446,29 @@ class EpollSelector(_PollLikeSelector): | |
| _EVENT_READ = select.EPOLLIN | ||
| _EVENT_WRITE = select.EPOLLOUT | ||
|
|
||
| def __init__(self): | ||
| super().__init__() | ||
| self._exclusive = False | ||
|
|
||
| @property | ||
| def exclusive(self): | ||
| return self._exclusive | ||
|
|
||
| def set_exclusive(self, value): | ||
|
Comment thread
Outdated
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySo far selectors haven't had this but looking at asyncio, ssl, socket, threading, and multiprocessing code, we usually either use properties for both getting and setting a value, or we use both a get_* and a set_* method. Since we already have get_key and get_map in selectors.py, and there are no public fields nor properties here, I'd change the exclusive getter to an explicit get_exclusive() method.
Sorry, something went wrong.
All reactions
|
||
| if not isinstance(value, bool): | ||
| raise ValueError("Not a boolean") | ||
| if not hasattr(select, "EPOLLEXCLUSIVE"): | ||
| raise ValueError("Python was not compiled " | ||
| "with EPOLLEXCLUSIVE") | ||
| self._exclusive = value | ||
|
|
||
| def register(self, fileobj, events, data=None): | ||
| register_flags = 0 | ||
| if self._exclusive: | ||
| register_flags |= select.EPOLLEXCLUSIVE | ||
| return super().register(fileobj, events, | ||
| data=data, register_flags=register_flags) | ||
|
|
||
| def fileno(self): | ||
| return self._selector.fileno() | ||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| :func:`selectors.EpollSelector.set_exclusive` added to enable setting *EPOLLEXCLUSIVE* automatically on polled file descriptors. |
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySince this is in a method literally called register, I'd name the new argument simply flags.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.