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
|
@ -175,6 +175,8 @@ class BaseSelector(metaclass=ABCMeta):
|
||||||
"""
|
"""
|
||||||
mapping = self.get_map()
|
mapping = self.get_map()
|
||||||
try:
|
try:
|
||||||
|
if mapping is None:
|
||||||
|
raise KeyError
|
||||||
return mapping[fileobj]
|
return mapping[fileobj]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise KeyError("{!r} is not registered".format(fileobj)) from None
|
raise KeyError("{!r} is not registered".format(fileobj)) from None
|
||||||
|
@ -256,6 +258,7 @@ class _BaseSelectorImpl(BaseSelector):
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._fd_to_key.clear()
|
self._fd_to_key.clear()
|
||||||
|
self._map = None
|
||||||
|
|
||||||
def get_map(self):
|
def get_map(self):
|
||||||
return self._map
|
return self._map
|
||||||
|
|
|
@ -180,6 +180,7 @@ class BaseSelectorTestCase(unittest.TestCase):
|
||||||
s = self.SELECTOR()
|
s = self.SELECTOR()
|
||||||
self.addCleanup(s.close)
|
self.addCleanup(s.close)
|
||||||
|
|
||||||
|
mapping = s.get_map()
|
||||||
rd, wr = self.make_socketpair()
|
rd, wr = self.make_socketpair()
|
||||||
|
|
||||||
s.register(rd, selectors.EVENT_READ)
|
s.register(rd, selectors.EVENT_READ)
|
||||||
|
@ -188,6 +189,8 @@ class BaseSelectorTestCase(unittest.TestCase):
|
||||||
s.close()
|
s.close()
|
||||||
self.assertRaises(KeyError, s.get_key, rd)
|
self.assertRaises(KeyError, s.get_key, rd)
|
||||||
self.assertRaises(KeyError, s.get_key, wr)
|
self.assertRaises(KeyError, s.get_key, wr)
|
||||||
|
self.assertRaises(KeyError, mapping.__getitem__, rd)
|
||||||
|
self.assertRaises(KeyError, mapping.__getitem__, wr)
|
||||||
|
|
||||||
def test_get_key(self):
|
def test_get_key(self):
|
||||||
s = self.SELECTOR()
|
s = self.SELECTOR()
|
||||||
|
|
|
@ -44,6 +44,10 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #23209, #23225: selectors.BaseSelector.close() now clears its internal
|
||||||
|
reference to the selector mapping to break a reference cycle. Initial patch
|
||||||
|
written by Martin Richard.
|
||||||
|
|
||||||
- Issue #21356: Make ssl.RAND_egd() optional to support LibreSSL. The
|
- Issue #21356: Make ssl.RAND_egd() optional to support LibreSSL. The
|
||||||
availability of the function is checked during the compilation. Patch written
|
availability of the function is checked during the compilation. Patch written
|
||||||
by Bernard Spil.
|
by Bernard Spil.
|
||||||
|
|
Loading…
Reference in New Issue