mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
reference to the selector mapping to break a reference cycle. Initial patch written by Martin Richard.
This commit is contained in:
parent
d9fe22ce9b
commit
38dc250521
3 changed files with 10 additions and 0 deletions
|
@ -175,6 +175,8 @@ class BaseSelector(metaclass=ABCMeta):
|
|||
"""
|
||||
mapping = self.get_map()
|
||||
try:
|
||||
if mapping is None:
|
||||
raise KeyError
|
||||
return mapping[fileobj]
|
||||
except KeyError:
|
||||
raise KeyError("{!r} is not registered".format(fileobj)) from None
|
||||
|
@ -256,6 +258,7 @@ class _BaseSelectorImpl(BaseSelector):
|
|||
|
||||
def close(self):
|
||||
self._fd_to_key.clear()
|
||||
self._map = None
|
||||
|
||||
def get_map(self):
|
||||
return self._map
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue