From cb9d910a0599cdb5a90f3c08c850c08c822d9073 Mon Sep 17 00:00:00 2001 From: James Teh Date: Wed, 1 Apr 2020 04:52:01 +1000 Subject: [PATCH] Fix OSError exception after 5 seconds when calling pyia.Registry.start(). This is a bug in comtypes with Python 3: https://github.com/enthought/comtypes/issues/138 It's been fixed, but hasn't been released yet: https://github.com/enthought/comtypes/commit/36719c82 It doesn't seem like a release is coming any time soon, so rather than forcing pyia consumers to install comtypes from git, just work around it for now. --- pyia/registry.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pyia/registry.py b/pyia/registry.py index a522472..34e6bd4 100644 --- a/pyia/registry.py +++ b/pyia/registry.py @@ -32,6 +32,8 @@ from event import Event from utils import accessibleObjectFromEvent +RPC_S_CALLPENDING = -2147417835 + class Registry(object): def __init__(self): self.clients = {} @@ -87,8 +89,15 @@ def clearListeners(self): def iter_loop(self, timeout=1): - PumpEvents(timeout) - + try: + PumpEvents(timeout) + except OSError as e: + # Work around https://github.com/enthought/comtypes/issues/138. + # RPC_S_CALLPENDING just means the timeout expired, so we can + # ignore it. + if e.winerror != RPC_S_CALLPENDING: + raise + def start(self): while True: try: