[pypy-svn] r42171 - pypy/branch/lib-distributed-rewrite/pypy/lib/distributed
fijal at codespeak.net
fijal at codespeak.net
Thu Apr 19 14:05:02 CEST 2007
Author: fijal
Date: Thu Apr 19 14:05:02 2007
New Revision: 42171
Added:
pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/faker.py
Modified:
pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/objkeeper.py
pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/protocol.py
Log:
Check (completely broken) wc changes to avoid # XXX jeez comment
Added: pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/faker.py
==============================================================================
--- (empty file)
+++ pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/faker.py Thu Apr 19 14:05:02 2007
@@ -0,0 +1,31 @@
+
+""" This file is responsible for faking types
+"""
+
+class GetSetDescriptor(object):
+ def __init__(self, protocol):
+ self.protocol = protocol
+
+ def __get__(self, obj, type=None):
+ return self.protocol.get(obj, type)
+
+ def __set__(self, obj, value):
+ self.protocol.set(obj, value)
+
+class GetDescriptor(object):
+ def __init__(self, protocol):
+ self.protocol = protocol
+
+ def __get__(self, obj, type=None):
+ return self.protocol.get(obj, type)
+
+# these are one-go functions for wrapping/unwrapping types,
+# note that actual caching is defined in other files,
+# this is only the case when we *need* to wrap/unwrap
+# type
+
+def wrap_type(tp):
+ pass
+
+def unwrap_type(name, bases_w, dict_w):
+ pass
Modified: pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/objkeeper.py
==============================================================================
--- pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/objkeeper.py (original)
+++ pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/objkeeper.py Thu Apr 19 14:05:02 2007
@@ -2,19 +2,8 @@
""" objkeeper - Storage for remoteprotocol
"""
-# XXX jeez
-
-import sys
-try:
- 1/0
-except:
- _, _, tb = sys.exc_info()
- GetSetDescriptor = type(type(tb).tb_frame)
-
-class RemoteBase(object):
- pass
-
from types import FunctionType
+from distributed import faker
class ObjKeeper(object):
def __init__(self, exported_names = {}):
@@ -33,9 +22,10 @@
return len(self.exported_objects) - 1
def ignore(self, key, value):
- if key in ('__dict__', '__weakref__', '__class__'):
- return True
- if isinstance(value, GetSetDescriptor):
+ # there are some attributes, which cannot be modified later, nor
+ # passed into default values, ignore them
+ if key in ('__dict__', '__weakref__', '__class__',
+ '__dict__', '__bases__'):
return True
return False
@@ -51,6 +41,11 @@
# XXX: We don't support inheritance here, nor recursive types
# shall we???
+ ...
+ tp = faker.unwrap_type(tp, ...)
+
+
+
_dict = dict([(key, protocol.wrap(getattr(tp, key))) for key in dir(tp)
if not self.ignore(key, getattr(tp, key))])
protocol.send(("type_reg", (tp_id,
@@ -58,13 +53,15 @@
return tp_id
def fake_remote_type(self, protocol, type_id, _name, _dict):
+ ...
+
#print "Faking type %s as %s" % (_name, type_id)
# create and register new type
d = dict([(key, None) for key in _dict])
# some stuff needs to go first...
if '__doc__' in _dict:
d['__doc__'] = protocol.unwrap(_dict['__doc__'])
- tp = type(_name, (RemoteBase,), d)
+ tp = type(_name, (object,), d)
# Make sure we cannot instantiate the remote type
self.remote_types[type_id] = tp
self.reverse_remote_types[tp] = type_id
@@ -91,3 +88,4 @@
def get_remote_object(self, controller):
return self.remote_objects[controller]
+
Modified: pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/protocol.py
==============================================================================
--- pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/protocol.py (original)
+++ pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/protocol.py Thu Apr 19 14:05:02 2007
@@ -41,7 +41,7 @@
except ImportError:
raise ImportError("Cannot work without transparent proxy functionality")
-from distributed.objkeeper import ObjKeeper, RemoteBase
+from distributed.objkeeper import ObjKeeper
import sys
# XXX We do not make any garbage collection. We'll need it at some point
@@ -62,6 +62,10 @@
from marshal import dumps
import exceptions
+class RemoteBase(object):
+ pass
+# just placeholder for letter_types value
+
class AbstractProtocol(object):
immutable_primitives = (str, int, float, long, unicode, bool, types.NotImplementedType)
mutable_primitives = (list, dict, types.FunctionType, types.FrameType, types.TracebackType,
@@ -132,8 +136,10 @@
id = self.keeper.register_object(obj)
return (self.type_letters[tp], id)
elif tp is type:
- if issubclass(obj, RemoteBase):
+ try:
return "reg", self.keeper.reverse_remote_types[obj]
+ except KeyError:
+ pass
try:
return self.type_letters[tp], self.type_letters[obj]
except KeyError:
More information about the Pypy-commit
mailing list