コード例 #1
0
    print msg, '<request>'
    res = func(*args)
    print msg, '<response>', res


if __name__ == '__main__':
    #from netcall import setup_logger
    #setup_logger()

    pool = ThreadPool(128)
    spawn = lambda f, *ar, **kw: pool.schedule(f, args=ar, kwargs=kw)

    # Custom serializer/deserializer functions can be passed in. The server
    # side ones must match.
    echo = ThreadingRPCClient(pool=pool, serializer=JSONSerializer())
    echo.connect('tcp://127.0.0.1:5555')

    tasks = [
        spawn(printer, "[echo] Echoing \"Hi there\"", echo.echo, "Hi there")
    ]

    try:
        print "Testing a remote exception...",
        echo.error()
        print "FAIL, no remote exception!"
    except RemoteRPCError, e:
        print "OK, got an expected remote exception:"
        #print e.ename
        print e.evalue
        print e.traceback
コード例 #2
0
    "run a function, print results"
    print msg, '<request>'
    res = func(*args)
    print msg, '<response>', res

if __name__ == '__main__':
    #from netcall import setup_logger
    #setup_logger()

    pool  = ThreadPool(128)
    spawn = lambda f, *ar, **kw: pool.schedule(f, args=ar, kwargs=kw)

    # Custom serializer/deserializer functions can be passed in. The server
    # side ones must match.
    echo = ThreadingRPCClient(pool=pool, serializer=JSONSerializer())
    echo.connect('tcp://127.0.0.1:5555')

    tasks = [spawn(printer, "[echo] Echoing \"Hi there\"", echo.echo, "Hi there")]

    try:
        print "Testing a remote exception...",
        echo.error()
        print "FAIL, no remote exception!"
    except RemoteRPCError, e:
        print "OK, got an expected remote exception:"
        #print e.ename
        print e.evalue
        print e.traceback

    try:
        print "Testing a timeout...",