示例#1
0
 def echoer():
     yield tasklet.WaitForMessages(accept='echo-request')
     msg = tasklet.get_event()
     assert isinstance(msg, tasklet.Message)
     assert msg.sender is not None
     yield tasklet.Message('echo-reply',
                           dest=msg.sender,
                           value=msg.value)
示例#2
0
def process_stdout_sink(chan, buffer, view):
    timeout = tasklet.WaitForTimeout(200)
    iowait = tasklet.WaitForIO(chan, priority=1000)
    msgwait = tasklet.WaitForMessages(accept='quit')
    while True:
        yield iowait, msgwait
        ev = tasklet.get_event()
        if isinstance(ev, tasklet.Message) and ev.name == 'quit':
            return
        assert ev is iowait
        text = chan.read()
        buffer.insert(buffer.get_end_iter(), text)
        view.scroll_to_mark(buffer.get_insert(), 0)
        ## Now wait for some time, don't let process output "drown"
        ## the TextView updates
        yield timeout, tasklet.WaitForMessages(defer='quit')
        ev = tasklet.get_event()
        assert ev is timeout
示例#3
0
    def run(self):
        timeout = tasklet.WaitForTimeout(1000)
        msgwait = tasklet.WaitForMessages(accept='quit')

        for i in range(10, 0, -1):
            self.dialog.format_secondary_markup(
                "Time left: <b>%i</b> seconds" % i)

            yield timeout, msgwait
            ev = tasklet.get_event()

            if isinstance(ev, tasklet.Message) and ev.name == 'quit':
                return
            elif ev is timeout:
                pass
            else:
                raise AssertionError
示例#4
0
 def pinger(remote, value):
     yield tasklet.Message('echo-request', dest=remote, value=value)
     yield tasklet.WaitForMessages(accept='echo-reply')
     msg = tasklet.get_event()
     raise StopIteration(msg.value)