Example #1
0
 def two():
     rp = connect(('127.0.0.1', 21211), GreenSocket)
     assert rp.x.z == 3
Example #2
0
 def two():
     rp = connect(('127.0.0.1', 21211), GreenSocket)
     assert rp.x.z == 3
Example #3
0
""" This a sample client, suitable for use with server.py from this
directory

run by:
pypy-c client.py
"""

HOST = '127.0.0.1'
PORT = 12222

from distributed.socklayer import connect
remote_handle = connect((HOST, PORT))

import code
code.interact(local=locals())

""" Things that can be done: 1. remote object access

x = remote_handle.x
assert type(x) is remote_handle.X # typecheck
x.meth(lambda x: x + 10, 6) # remote call, with callback localy
x.meth(remote_handle.f, 3) # remote call, remote callback
remote_handle.sys._getframe(2).f_locals['x'] # remote frame access
# XXX should be 'is x' and shouldn't need (2) argument

# XXX next one does not work, while it should. Too much mangling with remote
# traceback frames probably
try:
  x.meth(1, 2) # non-callable argument, AssertionError
except:
  import sys
Example #4
0
""" This is sample client for a server based in fileserver.py, not counting
initialization, code.interact and __doc__ has just 2 lines! Usage:

pypy-c fileclient.py

The file_opener is a proxy for remote file object. Which means you can
perform same operations as locally, like file_opener('/etc/passwd').read()
or file_opener('/tmp/x', 'w').write('x')

pypy-c needs to be compiled with --allworkingmodules in order to have socket
working.
"""

HOST = '127.0.0.1'
PORT = 12221

from distributed.socklayer import connect
file_opener = connect((HOST, PORT)).open

import code
code.interact(local=locals())
# The file_opener is a proxy for remote file object. Which means you can
# perform same operations as locally, like file_opener('/etc/passwd').read()
# or file_opener('/tmp/x', 'w').write('x')
Example #5
0
 def two():
     rp = connect(('127.0.0.1', 21211), GreenSocket)
     assert rp.x.z == 3
     assert [i for i in dir(rp) if not i.startswith('__')] == ['x']