[pypy-svn] r47096 - pypy/dist/demo/distribution
fijal at codespeak.net
fijal at codespeak.net
Tue Oct 2 12:41:04 CEST 2007
Author: fijal
Date: Tue Oct 2 12:41:04 2007
New Revision: 47096
Added:
pypy/dist/demo/distribution/client.py (contents, props changed)
pypy/dist/demo/distribution/server.py (contents, props changed)
Log:
Intermediate version of some demos, will fix later (battery dead)
Added: pypy/dist/demo/distribution/client.py
==============================================================================
--- (empty file)
+++ pypy/dist/demo/distribution/client.py Tue Oct 2 12:41:04 2007
@@ -0,0 +1,16 @@
+""" 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())
+
Added: pypy/dist/demo/distribution/server.py
==============================================================================
--- (empty file)
+++ pypy/dist/demo/distribution/server.py Tue Oct 2 12:41:04 2007
@@ -0,0 +1,35 @@
+""" This is a demo exposing all globals from the current process over
+socket, to be accessible remotely.
+
+run by:
+pypy-c server.py
+
+pypy-c needs to be compiled with --allworkingmodules in order to have socket
+working.
+"""
+
+# things to export
+# function
+def f(x):
+ return x + 3
+
+# class
+class X:
+ def __init__(self):
+ self.slot = 3
+
+ def meth(self, f, arg):
+ """ Method eating callable and calling it with an argument
+ """
+ assert callable(f)
+ return f(arg)
+
+# object
+x = X()
+
+# constants
+HOST = '127.0.0.1'
+PORT = 12222
+
+from distributed.socklayer import socket_loop
+socket_loop((HOST, PORT), globals())
More information about the pypy-svn
mailing list