Exemple #1
0
class PubSubNode:
    def __init__(self):
        self.log = get_logger("PubSubNode")
        self.log.info("-- PubSubNode Init-ing --")

        self.reactor = ReactorInterface(self)
        self.reactor.execute(Command.ADD_SUB, url=URL, callback='do_something')
        self.reactor.execute(Command.ADD_PUB, url=URL)

        self.reactor.notify_ready()

    def do_something(self, data):
        self.log.debug("Doing something with data: {}".format(data))
Exemple #2
0
class SlowInitNode:
    def __init__(self):
        self.log = get_logger("SlowInitNode")
        self.log.info("-- Test Node Init-ing --")
        self.reactor = ReactorInterface(self)

        self.reactor.execute(Command.ADD_SUB, url=URL, callback='do_something_else')

        self.log.critical("Starting very slow init")
        time.sleep(6)
        self.log.critical("Done with very flow init")
        self.reactor.notify_ready()

    def do_something_slow(self, data):
        self.log.critical("Starting something slow with data: {}".format(data))
        time.sleep(2)
        self.log.critical("Done with something slow for data: {}".format(data))

    def do_something_else(self, data):
        self.log.info("do_something_ELSE with data: {}".format(data))