mirror of
https://github.com/python/cpython.git
synced 2025-10-11 09:23:31 +00:00
Issue #19842: Refactor BaseSelector to make it an actual usable ABC.
This commit is contained in:
parent
be0708f066
commit
b3330a0abf
3 changed files with 86 additions and 47 deletions
|
@ -142,9 +142,23 @@ def make_test_protocol(base):
|
|||
|
||||
class TestSelector(selectors.BaseSelector):
|
||||
|
||||
def __init__(self):
|
||||
self.keys = {}
|
||||
|
||||
def register(self, fileobj, events, data=None):
|
||||
key = selectors.SelectorKey(fileobj, 0, events, data)
|
||||
self.keys[fileobj] = key
|
||||
return key
|
||||
|
||||
def unregister(self, fileobj):
|
||||
return self.keys.pop(fileobj)
|
||||
|
||||
def select(self, timeout):
|
||||
return []
|
||||
|
||||
def get_map(self):
|
||||
return self.keys
|
||||
|
||||
|
||||
class TestLoop(base_events.BaseEventLoop):
|
||||
"""Loop for unittests.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue