From 7e7a3dba5fd4262269f713dfe21ba7e4746fc2dd Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 10 Apr 2015 13:24:41 +0300 Subject: Issue #23865: close() methods in multiple modules now are idempotent and more robust at shutdown. If needs to release multiple resources, they are released even if errors are occured. --- Lib/selectors.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Lib/selectors.py') diff --git a/Lib/selectors.py b/Lib/selectors.py index beb7ef7741..7b6da29863 100644 --- a/Lib/selectors.py +++ b/Lib/selectors.py @@ -445,8 +445,10 @@ if hasattr(select, 'epoll'): return ready def close(self): - self._epoll.close() - super().close() + try: + self._epoll.close() + finally: + super().close() if hasattr(select, 'kqueue'): @@ -517,8 +519,10 @@ if hasattr(select, 'kqueue'): return ready def close(self): - self._kqueue.close() - super().close() + try: + self._kqueue.close() + finally: + super().close() # Choose the best implementation: roughly, epoll|kqueue > poll > select. -- cgit v1.2.1