[pypy-svn] r39633 - pypy/dist/pypy/lib/distributed/demo
fijal at codespeak.net
fijal at codespeak.net
Thu Mar 1 15:03:44 CET 2007
Author: fijal
Date: Thu Mar 1 15:03:42 2007
New Revision: 39633
Added:
pypy/dist/pypy/lib/distributed/demo/gsock.py
Log:
(fijal, guido) add a cool demo about lib/distributed
Added: pypy/dist/pypy/lib/distributed/demo/gsock.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lib/distributed/demo/gsock.py Thu Mar 1 15:03:42 2007
@@ -0,0 +1,38 @@
+
+from distributed import RemoteProtocol, remote_loop
+
+class X:
+ def __init__(self, z):
+ self.z = z
+
+ def meth(self, x):
+ return self.z + x()
+
+ def raising(self):
+ 1/0
+
+x = X(3)
+
+def remote():
+ from distributed.socklayer import socket_listener
+ send, receive = socket_listener()
+ remote_loop(RemoteProtocol(send, receive, globals()))
+
+def local():
+ from distributed.socklayer import socket_connecter
+ send, receive = socket_connecter(('localhost', 12121))
+ return RemoteProtocol(send, receive)
+
+import sys
+if __name__ == '__main__':
+ if len(sys.argv) > 1 and sys.argv[1] == '-r':
+ remote()
+ else:
+ rp = local()
+ x = rp.get_remote("x")
+ try:
+ x.raising()
+ except:
+ import sys
+ import pdb
+ pdb.post_mortem(sys.exc_info()[2])
More information about the Pypy-commit
mailing list