Skip to content

WinError on PumpEvents timeout #138

@HudsonMC16

Description

@HudsonMC16

The CoWaitForMultipleHandles call in the PumpEvents function throws a WindowsError on timeout. Currently, the except statement checks details.args[0] against RPC_S_CALLPENDING (previously defined as -2147417835, which is the winerror number). Details.args[0] contains the "errno". The number we're looking for is in details.args[3], but I think it might be better to refer to details.winerror instead.

I think it should read:

    try:
        try:
            res = ctypes.oledll.ole32.CoWaitForMultipleHandles(0,
                                                               int(timeout * 1000),
                                                               len(handles), handles,
                                                               ctypes.byref(ctypes.c_ulong()))
        except WindowsError as details:
            if details.winerror != RPC_S_CALLPENDING: # timeout expired
                raise
        else:
            raise KeyboardInterrupt
    finally:
        ctypes.windll.kernel32.CloseHandle(hevt)
        ctypes.windll.kernel32.SetConsoleCtrlHandler(HandlerRoutine, 0)

I'm pretty new to all this, but that is how I got it to work in my code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions