def dog(): meow = fibra.Tube("meow") woof = fibra.Tube("woof") while True: yield woof.push("woof") m = yield meow.pop(wait=True)
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)
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()
def send(): output = fibra.Tube("log_service") yield output.push("hello!", wait=False) print('pushed')
def cat(): meow = fibra.Tube("meow") woof = fibra.Tube("woof") for i in range(1000): m = yield woof.pop() yield meow.push("meow")
def task_d(): tube = fibra.Tube("Named Tube") x = yield tube.pop() print("Received from Named Tube:", x)
def task_c(): tube = fibra.Tube("Named Tube") yield tube.push('this string is pushed into a named tube.')
def __init__(self, transport): self.running = True self.protocol = Protocol(transport) self.outbox = fibra.Tube() schedule.install(self.start())
def __init__(self, name, circle): self.name = name self.circle = circle circle.append(self) self.messageQueue = fibra.Tube() scheduler.install(self.messageLoop())
def main(): t = fibra.Tube() schedule = fibra.schedule() schedule.install(a(t)) schedule.install(b(t)) schedule.run()