From b794153a5744afecb4113f3f814a5c94695e9f76 Mon Sep 17 00:00:00 2001 From: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> Date: Sun, 17 Sep 2023 22:04:43 +0200 Subject: [PATCH] Catch `pywintypes.error` in broadcast manager (#1659) --- can/broadcastmanager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/can/broadcastmanager.py b/can/broadcastmanager.py index 84554a507..a017b7d52 100644 --- a/can/broadcastmanager.py +++ b/can/broadcastmanager.py @@ -22,6 +22,7 @@ # try to import win32event for event-based cyclic send task (needs the pywin32 package) USE_WINDOWS_EVENTS = False try: + import pywintypes import win32event # Python 3.11 provides a more precise sleep implementation on Windows, so this is not necessary. @@ -263,7 +264,7 @@ def __init__( win32event.CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, win32event.TIMER_ALL_ACCESS, ) - except (AttributeError, OSError): + except (AttributeError, OSError, pywintypes.error): self.event = win32event.CreateWaitableTimer(None, False, None) self.start()