Tuesday, March 03, 2009

Fibra grows Tubes.

Tubes are like pipes, but... different. Anyhow, Fibra 0.0.9 includes some new Tube classes for communicating amongst tasks.
import fibra

def a(tube):
print 'Pushing "a" into tube.'
tube.push('a')
yield None

def b(tube):
while True:
x = yield tube.pop()
print 'Received "%s" from tube.'%x

t = fibra.Tube()
schedule = fibra.schedule()
schedule.install(a(t))
schedule.install(b(t))
schedule.run()

No comments:

Popular Posts