mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
RuntimeError if the selector is closed. And selectors.BaseSelector.close() now clears its internal reference to the selector mapping to break a reference cycle. Initial patch written by Martin Richard.
This commit is contained in:
commit
458fc6f98c
3 changed files with 15 additions and 4 deletions
|
@ -174,6 +174,8 @@ class BaseSelector(metaclass=ABCMeta):
|
|||
SelectorKey for this file object
|
||||
"""
|
||||
mapping = self.get_map()
|
||||
if mapping is None:
|
||||
raise RuntimeError('Selector is closed')
|
||||
try:
|
||||
return mapping[fileobj]
|
||||
except KeyError:
|
||||
|
@ -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