diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-13 09:00:55 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-13 09:00:55 (GMT) |
commit | 458fc6f98ca9a838af5dcdff64fd48ae3eb64fa9 (patch) | |
tree | 2f5ebe056493b3bc7ed8931fb9ca141fd150340d /Lib/selectors.py | |
parent | 17cba7daf5cdbe2a0e589be9ef507408b8dc07f1 (diff) | |
parent | 38dc250521d2c34f58537b25301a0ac9a4bb6c85 (diff) | |
download | cpython-458fc6f98ca9a838af5dcdff64fd48ae3eb64fa9.zip cpython-458fc6f98ca9a838af5dcdff64fd48ae3eb64fa9.tar.gz cpython-458fc6f98ca9a838af5dcdff64fd48ae3eb64fa9.tar.bz2 |
Issue #23209, #23225: selectors.BaseSelector.get_key() now raises a
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.
Diffstat (limited to 'Lib/selectors.py')
-rw-r--r-- | Lib/selectors.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/selectors.py b/Lib/selectors.py index 598845d4..6d569c3 100644 --- a/Lib/selectors.py +++ b/Lib/selectors.py @@ -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 |