예제 #1
0
def main(environ, argv):
    greenhouse.global_exception_handler(traceback.print_exception)
    junction.configure_logging(level=1)

    hub = junction.Hub(("", 9057), [("", 9056)])
    hub.start()

    greenhouse.Event().wait()
예제 #2
0
파일: service.py 프로젝트: teepark/junction
def main(environ, argv):
    greenhouse.global_exception_handler(traceback.print_exception)
    junction.configure_logging(level=1)

    hub = junction.Hub(("", 9056), [])
    hub.accept_rpc('service', 0, 0, 'echostream', handle)
    hub.start()

    greenhouse.Event().wait()
예제 #3
0
def main(environ, argv):
    greenhouse.global_exception_handler(traceback.print_exception)
    junction.configure_logging(level=1)

    hub = junction.Hub(("", 9056), [])
    hub.accept_rpc('service', 0, 0, 'echostream', handle)
    hub.start()

    greenhouse.Event().wait()
예제 #4
0
def main(environ, argv):
    greenhouse.global_exception_handler(traceback.print_exception)
    junction.configure_logging(level=1)

    port = 9056
    if argv[1:] and argv[1] == 'relay':
        port += 1

    #client = junction.Client(("", port))
    #client.connect()
    client = junction.Hub(("", port + 1), [("", port)])
    client.start()

    client.wait_connected()

    for line in client.rpc('service', 0, 'echostream', (gen_input(), )):
        print 'line:', line
예제 #5
0
파일: client.py 프로젝트: teepark/junction
def main(environ, argv):
    greenhouse.global_exception_handler(traceback.print_exception)
    junction.configure_logging(level=1)

    port = 9056
    if argv[1:] and argv[1] == 'relay':
        port += 1

    #client = junction.Client(("", port))
    #client.connect()
    client = junction.Hub(("", port+1), [("", port)])
    client.start()

    client.wait_connected()

    for line in client.rpc(
            'service', 0, 'echostream', (gen_input(),)):
        print 'line:', line
예제 #6
0
    def test_global_exception_handlers(self):
        class CustomError(Exception):
            pass

        @greenhouse.schedule
        def f():
            raise CustomError()

        l = []

        def handler(klass, exc, tb):
            l.append(klass)

        greenhouse.global_exception_handler(handler)

        greenhouse.pause()

        self.assertEqual(len(l), 1)
        self.assertEqual(l[0], CustomError)
예제 #7
0
    def test_global_exception_handlers(self):
        class CustomError(Exception):
            pass

        @greenhouse.schedule
        def f():
            raise CustomError()

        l = []

        def handler(klass, exc, tb):
            l.append(klass)

        greenhouse.global_exception_handler(handler)

        greenhouse.pause()

        self.assertEqual(len(l), 1)
        self.assertEqual(l[0], CustomError)
예제 #8
0
            code.co_name,
            code.co_firstlineno,
            code.co_lnotab,
            code.co_freevars,
            code.co_cellvars))

def load_func(s):
    def func():
        pass
    code = type(load_func.func_code)(*mummy.loads(s))
    func.func_code = code
    return func


if __name__ == '__main__':
    greenhouse.global_exception_handler(traceback.print_exception)
    junction.configure_logging(level=1)

    if sys.argv[1] == "mapper":
        hub = junction.Hub(("", 9090), [("", 9091), ("", 9092)])
        hub.start()
        mapper = Mapper(hub, 'map-reduce', 1)
        greenhouse.run_backdoor(("", 8090), locals())
    elif sys.argv[1] == "reducer":
        hub = junction.Hub(("", 9091), [("", 9090), ("", 9092)])
        hub.start()
        reducer = Reducer(hub, 'map-reduce', 0, 0)
        greenhouse.run_backdoor(("", 8091), locals())
    elif sys.argv[1] == "coordinator":
        hub = junction.Hub(("", 9092), [("", 9090), ("", 9091)])
        hub.start()
예제 #9
0
#!/usr/bin/env python
# vim: fileencoding=utf8:et:sta:ai:sw=4:ts=4:sts=4

import random
import traceback

import greenhouse
import junction

greenhouse.global_exception_handler(traceback.print_exception)


SERVICE_PORT = 9870
WAIT_SERVICE = 1


def main():
    client = junction.Client(("localhost", SERVICE_PORT))
    client.connect()
    client.wait_connected()

    print "wait 2"
    client.rpc(WAIT_SERVICE, 0, "wait", (2,))

    rpcs = []
    for i in xrange(5):
        wait = random.random() * 5
        rpc = client.send_rpc(WAIT_SERVICE, 0, "wait", (wait,))
        rpc.counter = i
        rpcs.append(rpc)
        print "queued a wait %r: %r" % (rpcs[-1].counter, wait)