Ejemplo n.º 1
0
def main():
    eb = eventbus()
    parser = MessageParser(eb)

    cv = threading.Condition()  #conditional Variable
    teq = TimeEventQueuer(eb, cv)
    teq.start()

    internet_check = InternetStatus(eb)
    weather_forcast = WeatherForcast(eb)

    client = FbClient(eb, parser)
    client.start()
    #eb.post(event(EVENTID_CLIENT_START,""))
    """
    print("Joining")
    while(client.isAlive()):
        time.sleep(1)
    client.join() 
    """
    client.join()
    print("Exiting Main Thread")
    eb.post(event(EVENTID_QUEUE_STOP, ""))
    teq.join()
    eb.shutdown()
Ejemplo n.º 2
0
def main():
    init_logging('/tmp/lockserver.log')
    ebus = eventbus()
    clients = Clients(ebus)
    clients.setDaemon(True)
    clients.start()
    lc = LockContainer(ebus)
    ebus.register_consumer(lc, common.LOCKOP_TOPIC)
    ebus.register_consumer(lc, common.UNREGISTER_TOPIC)
    ebus.register_consumer(clients, common.RESPONSE_TOPIC)
    f = DistComFactory(ebus)
    f.protocol = DistLockComm
    reactor.listenTCP(8000, f)
    reactor.run()
Ejemplo n.º 3
0
 def test_asynchronus_eventbus(self):
     global ebus
     self.ebus = eventbus(subscribers_thread_safe=False)
     ebus = self.ebus
     self.assertTrue(self.alltests())
Ejemplo n.º 4
0
 def test_synchronus_eventbus(self):
     global ebus
     self.ebus = eventbus(synchronus=True)
     ebus = self.ebus
     self.assertTrue(self.alltests())
Ejemplo n.º 5
0
        self.ebus = ebus
        self.keep_running = True
        self.num_counter = len(counters)

    def stop(self):
        self.keep_running = False

    def __call__(self):
        while self.keep_running:
            ev = event(self.counters[randint(0, self.num_counter - 1)], randint(1, 100))
            ebus.post(ev)
            sleep(0.02)
        print('producer exited')

if __name__ == '__main__':
    ebus = eventbus()
    counters = ['c1', 'c2', 'c3', 'c4']
    subcr = counter_aggregator(counters)
    producer = count_producer(counters, ebus)
    for counter in counters:
        ebus.register_consumer(subcr, counter)
    threads = []
    i = 30
    while i > 0:
        threads.append(Thread(target=producer))
        i -= 1

    aggregator_thread = Thread(target=subcr)
    aggregator_thread.start()
    for thrd in threads:
        thrd.start()
Ejemplo n.º 6
0
        t_s = t.find(">", i_s)
        t_e = t.find("<", t_s)
        s = t[t_s + 1:t_e].encode(sys.stdout.encoding,
                                  errors="replace").decode("utf8")
        a = s.split()
        for i in range(len(a)):
            if (a[i].isdigit()):
                return a[i] + " m/s"

    def handle_subscription(self, subscription_event):
        sub = subscription_event.get_data()
        occ = sub.get_occurrence()
        interval = sub.get_interval()
        msg_data = sub.get_data()
        weather_event = event(EVENTID_WEATHER_CHECK, msg_data)
        rep_event = RepeatingEventObject(self.eb, weather_event, occ, interval,
                                         7)
        rep_event.queue()
        print("RepeatingEvent has been queued")

    def encode_print(self, text):
        print(text.encode(sys.stdout.encoding, errors='replace'))


if __name__ == "__main__":
    eb = eventbus()
    wf = WeatherForcast(eb)
    print(wf.get_weather())

    eb.shutdown()
Ejemplo n.º 7
0
 def __init__(self):
     self.eb = eventbus()
Ejemplo n.º 8
0
 def test_asynchronus_eventbus(self):
     global ebus
     self.ebus = eventbus(subscribers_thread_safe=False)
     ebus = self.ebus
     self.assertTrue(self.alltests())
Ejemplo n.º 9
0
 def test_synchronus_eventbus(self):
     global ebus
     self.ebus = eventbus(synchronus=True)
     ebus = self.ebus
     self.assertTrue(self.alltests())