def wait_on_event(library, session, in_event_type, timeout):
    """Waits for an occurrence of the specified event for a given session.

    Corresponds to viWaitOnEvent function of the VISA library.

    :param library: the visa library wrapped by ctypes.
    :param session: Unique logical identifier to a session.
    :param in_event_type: Logical identifier of the event(s) to wait for.
    :param timeout: Absolute time period in time units that the resource shall wait for a specified event to
                    occur before returning the time elapsed error. The time unit is in milliseconds.
    :return: - Logical identifier of the event actually received
             - A handle specifying the unique occurrence of an event
             - return value of the library call.
    :rtype: - eventtype
            - event
            - :class:`pyvisa.constants.StatusCode`
    """
    out_event_type = ViEventType()
    out_context = ViEvent()
    ret = library.viWaitOnEvent(session, in_event_type, timeout,
                                byref(out_event_type), byref(out_context))
    return out_event_type.value, out_context, ret
Waits for an occurrence of the specified event for a given session.

    Corresponds to viWaitOnEvent function of the VISA library.

    :param library: the visa library wrapped by ctypes.
    :param session: Unique logical identifier to a session.
    :param in_event_type: Logical identifier of the event(s) to wait for.
    :param timeout: Absolute time period in time units that the resource shall wait for a specified event to
                    occur before returning the time elapsed error. The time unit is in milliseconds.
    :return: - Logical identifier of the event actually received
             - A handle specifying the unique occurrence of an event
             - return value of the library call.
    :rtype: - eventtype
            - event
            - :class:`pyvisa.constants.StatusCode`