[pypy-svn] r42412 - pypy/dist/pypy/lib/distributed/demo

fijal at codespeak.net fijal at codespeak.net
Sat Apr 28 21:00:40 CEST 2007


Author: fijal
Date: Sat Apr 28 21:00:40 2007
New Revision: 42412

Added:
   pypy/dist/pypy/lib/distributed/demo/fileclient.py
   pypy/dist/pypy/lib/distributed/demo/fileserver.py
Log:
Famous 2-line fileserver now working :)


Added: pypy/dist/pypy/lib/distributed/demo/fileclient.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lib/distributed/demo/fileclient.py	Sat Apr 28 21:00:40 2007
@@ -0,0 +1,14 @@
+
+""" This is sample client for a server based in fileserver.py, not counting
+initialization and __doc__ has just 2 lines. Usage:
+
+pypy-c -i fileclient.py
+"""
+HOST = '127.0.0.1'
+PORT = 12221
+
+from distributed.socklayer import connect
+file_opener = connect((HOST, PORT)).get_remote('open')
+
+# now you can do for example file_opener('/etc/passwd').read() to
+# read remote /etc/passwd

Added: pypy/dist/pypy/lib/distributed/demo/fileserver.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lib/distributed/demo/fileserver.py	Sat Apr 28 21:00:40 2007
@@ -0,0 +1,14 @@
+""" This is sample demo about how flexible pypy distribution is.
+Not counting __doc__ and initialization this is 2 line,
+fully operational file server,
+sample client which is in fileclient.py is included as well.
+
+Note that you must run it with pypy-c compiled with transparent proxy
+and allworkingmodules (or at least socket and select)
+"""
+
+HOST = '127.0.0.1' # defaults to localhost, not to export your files
+PORT = 12221
+
+from distributed.socklayer import socket_loop
+socket_loop((HOST, PORT), {'open':open})



More information about the Pypy-commit mailing list