Beispiel #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()
Beispiel #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()
Beispiel #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()
Beispiel #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()
Beispiel #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()