Esempio n. 1
0
        print "%r multiply %r %r" % (self.bound, a, b)
        return a*b

    def divide(self, a, b):
        print "%r divide %r %r" % (self.bound, a, b)
        return a/b


if __name__ == '__main__':
    echo.bind('tcp://127.0.0.1:5555')

    # We create two Math services to simulate load balancing. A client can
    # connect to both of these services and requests will be load balanced.
    math1 = Math()
    math2 = Math()

    math1.bind('tcp://127.0.0.1:5556')
    math2.bind('tcp://127.0.0.1:5557')

    # another way of defining tasks
    math2.register(echo_error, name='error')
    math2.register(echo_sleep, name='sleep')

    # now we spawn service greenlets and wait for them to exit
    joinall([
        echo.start(),
        math1.start(),
        math2.start()
    ])

Esempio n. 2
0
    def subtract(self, a, b):
        print "%r subtract %r %r" % (self.bound, a, b)
        return a - b

    def multiply(self, a, b):
        print "%r multiply %r %r" % (self.bound, a, b)
        return a * b

    def divide(self, a, b):
        print "%r divide %r %r" % (self.bound, a, b)
        return a / b


if __name__ == '__main__':
    echo.bind('tcp://127.0.0.1:5555')

    # We create two Math services to simulate load balancing. A client can
    # connect to both of these services and requests will be load balanced.
    math1 = Math()
    math2 = Math()

    math1.bind('tcp://127.0.0.1:5556')
    math2.bind('tcp://127.0.0.1:5557')

    # another way of defining tasks
    math2.register(echo_error, name='error')
    math2.register(echo_sleep, name='sleep')

    # now we spawn service greenlets and wait for them to exit
    joinall([echo.start(), math1.start(), math2.start()])
Esempio n. 3
0
        return a * b

    def divide(self, a, b):
        print "%r divide %r %r" % (self.bound, a, b)
        return a / b


if __name__ == '__main__':
    echo.bind('tcp://127.0.0.1:5555')

    # We create two Math services to simulate load balancing. A client can
    # connect to both of these services and requests will be load balanced.
    math1 = Math()
    math2 = Math()

    math1.bind('tcp://127.0.0.1:5556')
    math2.bind('tcp://127.0.0.1:5557')

    # another way of defining tasks
    math2.register(echo_error, name='error')
    math2.register(echo_sleep, name='sleep')

    # now we spawn service greenlets and wait for them to exit
    tasks = [
        echo.start(),
        math1.start(),
        math2.start(),
    ]
    for task in tasks:
        task.wait()