Exemplo n.º 1
0
def dog():
    meow = fibra.Tube("meow")
    woof = fibra.Tube("woof")

    while True:
        yield woof.push("woof")
        m = yield meow.pop(wait=True)
Exemplo n.º 2
0
def echo():
    input = fibra.Tube("log_service")
    yield 2
    while True:
        try:
            msg = yield input.pop(wait=True)
        except fibra.EmptyTube:
            print('no message')
            yield 1
        else:
            print(msg)
Exemplo n.º 3
0
def main():
    """
    >>> main()
    Received: this string is pushed to a waiting task
    Received from Named Tube: this string is pushed into a named tube.

    """
    t = fibra.Tube()
    schedule = fibra.schedule()
    schedule.install(task_a(t))
    schedule.install(task_b(t))
    schedule.install(task_c())
    schedule.install(task_d())
    schedule.run()
Exemplo n.º 4
0
def send():
    output = fibra.Tube("log_service")
    yield output.push("hello!", wait=False)
    print('pushed')
Exemplo n.º 5
0
def cat():
    meow = fibra.Tube("meow")
    woof = fibra.Tube("woof")
    for i in range(1000):
        m = yield woof.pop()
        yield meow.push("meow")
Exemplo n.º 6
0
def task_d():
    tube = fibra.Tube("Named Tube")
    x = yield tube.pop()
    print("Received from Named Tube:", x)
Exemplo n.º 7
0
def task_c():
    tube = fibra.Tube("Named Tube")
    yield tube.push('this string is pushed into a named tube.')
Exemplo n.º 8
0
 def __init__(self, transport):
     self.running = True
     self.protocol = Protocol(transport)
     self.outbox = fibra.Tube()
     schedule.install(self.start())
Exemplo n.º 9
0
 def __init__(self, name, circle):
     self.name = name
     self.circle = circle
     circle.append(self)
     self.messageQueue = fibra.Tube()
     scheduler.install(self.messageLoop())
Exemplo n.º 10
0
def main():
    t = fibra.Tube()
    schedule = fibra.schedule()
    schedule.install(a(t))
    schedule.install(b(t))
    schedule.run()