Table of Contents

Class: AnyOf ./src/peak/events/

Union of multiple event sources

Example usage:

        timedOut = scheduler.timeout(30)
        untilSomethingHappens = events.AnyOf(stream.dataRcvd, timedOut)

        while not timedOut():
            yield untilSomethingHappens; src,evt = events.resume()
            if src is stream.dataRcvd:
                data = event
                print data

AnyOf fires callbacks whenever any of its actual event sources fire (and allows tasks to continue if any of its actual event sources allow it). The event it supplies to its user is actually a (source,event) tuple as shown above, so you can distinguish which of the actual event sources fired, as well as receive the event from it.

Note that callbacks registered with an AnyOf instance will fire at most once, even if more than one of the original event sources fires. Thus, you should not assume in a callback or task that the event you received is the only one that has occurred. This is especially true in scheduled tasks, where many things may happen between the triggering of an event and the resumption of a task that was waiting for the event.

Base Classes   
__new__ ( klass,  *sources )

ValueError, "AnyOf must be called with one or more IEventSources"
addCallback ( self,  func )

See events.IEventSource.addCallback()

nextAction (

See events.ITaskSwitch.nextAction()

Table of Contents

This document was automatically generated on Mon Jun 1 01:11:15 2020 by HappyDoc version 2.1