Ejemplo n.º 1
0
 def setup(self):
     self.done = Countdown(10)
     self.fan = Fanout()
     self.subscriber_data = {}
     for x in xrange(10):
         diesel.fork(self.subscriber)
     diesel.sleep()
     for i in xrange(10):
         self.fan.pub(i)
     self.done.wait()
Ejemplo n.º 2
0
class FanoutHarness(object):
    def setup(self):
        self.done = Countdown(10)
        self.fan = Fanout()
        self.subscriber_data = {}
        for x in xrange(10):
            diesel.fork(self.subscriber)
        diesel.sleep()
        for i in xrange(10):
            self.fan.pub(i)
        self.done.wait()

    def subscriber(self):
        self.subscriber_data[uuid.uuid4()] = data = []
        with self.fan.sub() as q:
            for i in xrange(10):
                data.append(q.get())
        self.done.tick()
Ejemplo n.º 3
0
class FanoutHarness(object):
    def setup(self):
        self.done = Countdown(10)
        self.fan = Fanout()
        self.subscriber_data = {}
        for x in xrange(10):
            diesel.fork(self.subscriber)
        diesel.sleep()
        for i in xrange(10):
            self.fan.pub(i)
        self.done.wait()

    def subscriber(self):
        self.subscriber_data[uuid.uuid4()] = data = []
        with self.fan.sub() as q:
            for i in xrange(10):
                data.append(q.get())
        self.done.tick()
Ejemplo n.º 4
0
 def setup(self):
     self.done = Countdown(10)
     self.fan = Fanout()
     self.subscriber_data = {}
     for x in xrange(10):
         diesel.fork(self.subscriber)
     diesel.sleep()
     for i in xrange(10):
         self.fan.pub(i)
     self.done.wait()
Ejemplo n.º 5
0
from diesel import quickstart, quickstop, sleep
from diesel.util.queue import Fanout
from diesel.util.event import Countdown

LISTENERS = 10
EVENTS = 5

cd = Countdown(LISTENERS * EVENTS)

f = Fanout()


def listener(x):
    with f.sub() as q:
        while True:
            v = q.get()
            print '%s <- %s' % (x, v)
            cd.tick()


def teller():
    for x in xrange(EVENTS):
        sleep(2)
        f.pub(x)


def killer():
    cd.wait()
    quickstop()