Esempio n. 1
0
def do_echos():
    try:
        client = Client()
        yield client.connect('localhost', 8000)
        t = time.time()
        for x in xrange(10000):
            msg = "hello, world #%s!" % x
            yield client.write(msg + '\r\n')
            echo_result = yield client.read_until("\r\n")
            assert echo_result.strip() == "you said: %s" % msg
        print('10000 loops in %.2fs' % (time.time() - t))
    finally:
        client.close()
Esempio n. 2
0
def test_lots_of_messages():
    add_service(Service(handle_echo, port=8000))
    try:
        client = Client()
        yield client.connect('localhost', 8000)
        t = time.time()
        for x in xrange(10000):
            msg = "hello, world #%s!" % x
            yield client.write(msg + '\r\n')
            echo_result = yield client.read_until("\r\n")
            assert echo_result.strip() == "you said: %s" % msg
        print '10000 loops in %.2fs' % (time.time() - t)
    finally:
        client.close()
Esempio n. 3
0
def _subproc_wrapper(port, target, *args, **kwargs):
    try:
        client = Client()
        while True:
            try:
                yield client.connect('127.0.0.1', port)
                break
            except Exception as e:
                print("failed to connect to monocle multiprocess parent on port", port, type(e), str(e))
                yield sleep(1)
        chan = SocketChannel(client)
        yield target(chan, *args, **kwargs)
    finally:
        client.close()
Esempio n. 4
0
def _subproc_wrapper(port, target, *args, **kwargs):
    try:
        client = Client()
        while True:
            try:
                yield client.connect('127.0.0.1', port)
                break
            except Exception as e:
                print(
                    "failed to connect to monocle multiprocess parent on port",
                    port, type(e), str(e))
                yield sleep(1)
        chan = SocketChannel(client)
        yield target(chan, *args, **kwargs)
    finally:
        client.close()
Esempio n. 5
0
def main():
    c = Client()
    yield c.connect('google.com', 80)
    c.close()
    yield c.connect('google.com', 80, timeout=0)