[pypy-svn] r42943 - in pypy/dist/pypy/lib/distributed: . test
fijal at codespeak.net
fijal at codespeak.net
Wed May 9 14:51:11 CEST 2007
Author: fijal
Date: Wed May 9 14:51:10 2007
New Revision: 42943
Modified:
pypy/dist/pypy/lib/distributed/protocol.py
pypy/dist/pypy/lib/distributed/test/test_distributed.py
Log:
Possibility of listing keys
Modified: pypy/dist/pypy/lib/distributed/protocol.py
==============================================================================
--- pypy/dist/pypy/lib/distributed/protocol.py (original)
+++ pypy/dist/pypy/lib/distributed/protocol.py Wed May 9 14:51:10 2007
@@ -335,6 +335,9 @@
value = protocol.unwrap(w_value)
getattr(type(obj), name).__set__(obj, value)
send(('finished', protocol.wrap(None)))
+ elif command == 'remote_keys':
+ keys = protocol.keeper.exported_names.keys()
+ send(('finished', protocol.wrap(keys)))
else:
raise NotImplementedError("command %s" % command)
@@ -389,12 +392,15 @@
def get(self, name, obj, type):
self.send(("desc_get", (name, self.wrap(obj), self.wrap(type))))
- retval = remote_loop(self)
- return retval
+ return remote_loop(self)
def set(self, obj, value):
self.send(("desc_set", (name, self.wrap(obj), self.wrap(value))))
+ def remote_keys(self):
+ self.send(("remote_keys",None))
+ return remote_loop(self)
+
class RemoteObject(object):
def __init__(self, protocol, id):
self.id = id
Modified: pypy/dist/pypy/lib/distributed/test/test_distributed.py
==============================================================================
--- pypy/dist/pypy/lib/distributed/test/test_distributed.py (original)
+++ pypy/dist/pypy/lib/distributed/test/test_distributed.py Wed May 9 14:51:10 2007
@@ -298,3 +298,7 @@
protocol = self.test_env({})
raises(ObjectNotFound, "protocol.get_remote('x')")
+ def test_list_items(self):
+ protocol = self.test_env({'x':3, 'y':8})
+ assert sorted(protocol.remote_keys()) == ['x', 'y']
+
More information about the pypy-svn
mailing list