On this page
selectors.SelectorKey
Prev: selectors.PollSelector | Up: selectors | Next: selectors.SelectSelector
Rel: selectors.ABCMeta, selectors.abstractmethod, selectors.BaseSelector, selectors.DefaultSelector
Ref: docs.python.org โ selectors.SelectorKey
Tags: #public #python3 #stdlib #selectors
Import
import selectors
from selectors import SelectorKey
Signature & Overview
selectors.SelectorKey(fileobj, fd, events, data)
Object used to associate a file object to its backing file descriptor, selected event mask, and attached data.
Methods & Attributes
SelectorKey.count(self, value, /)โ Return number of occurrences of value.SelectorKey.index(self, value, start=0, stop=9223372036854775807, /)โ Return first index of value.
Usage
import selectors, socket
a, b = socket.socketpair()
with a, b, selectors.DefaultSelector() as sel:
key = sel.register(b, selectors.EVENT_READ, data='tag')
assert isinstance(key, selectors.SelectorKey) and key.data == 'tag'
Gotchas
- Named tuple
(fileobj, fd, events, data): Attach per-connection state indata=.
REPL Inspect
from selectors import SelectorKey
help(SelectorKey)
Linked from
Related notes
- tuts/python3/stdlib_module/selectors/PollSelector Linked here; links to this page; shared tags: #selectors, #stdlib
- tuts/python3/stdlib_module/selectors/SelectSelector Linked here; links to this page; shared tags: #selectors, #stdlib
- tuts/python3/stdlib_module/selectors Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/selectors/ABCMeta Linked here; shared tags: #selectors, #stdlib
- tuts/python3/stdlib_module/selectors/abstractmethod Linked here; shared tags: #selectors, #stdlib
- tuts/python3/stdlib_module/selectors/BaseSelector Linked here; shared tags: #selectors, #stdlib
- tuts/python3/stdlib_module/selectors/DefaultSelector Linked here; shared tags: #selectors, #stdlib
- tuts/python3/stdlib_module/selectors/KqueueSelector shared tags: #selectors, #stdlib
- tuts/python3/stdlib_module/selectors/Mapping shared tags: #selectors, #stdlib
- tuts/python3/stdlib_module/selectors/namedtuple shared tags: #selectors, #stdlib