From 563083cf866fb3473ac10364658c82a6925844e6 Mon Sep 17 00:00:00 2001 From: Kenneth Lyons Date: Sun, 23 Jun 2019 12:14:52 -0700 Subject: [PATCH] Handle invalid file descriptor in exit --- pyqtgraph/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/__init__.py b/pyqtgraph/__init__.py index 2db79985..b1aa98aa 100644 --- a/pyqtgraph/__init__.py +++ b/pyqtgraph/__init__.py @@ -369,8 +369,12 @@ def exit(): ## close file handles if sys.platform == 'darwin': for fd in range(3, 4096): - if fd not in [7]: # trying to close 7 produces an illegal instruction on the Mac. + if fd in [7]: # trying to close 7 produces an illegal instruction on the Mac. + continue + try: os.close(fd) + except OSError: + pass else: os.closerange(3, 4096) ## just guessing on the maximum descriptor count..