preparation to deallocate objects properly

This commit is contained in:
Philipp Moritz
2016-06-21 13:46:38 -07:00
parent 170a2ee8b1
commit 5281bd414f
6 changed files with 80 additions and 7 deletions
+27
View File
@@ -1,7 +1,34 @@
import importlib
import numpy as np
import ray
# The following definitions are required because Python doesn't allow custom
# attributes for primitive types. We need custom attributes for (a) implementing
# destructors that close the shared memory segment that the object resides in
# and (b) fixing https://github.com/amplab/ray/issues/72.
class Int(int):
pass
class Float(float):
pass
class List(list):
pass
class Dict(dict):
pass
class Tuple(tuple):
pass
class Str(str):
pass
class NDArray(np.ndarray):
pass
def to_primitive(obj):
if hasattr(obj, "serialize"):
primitive_obj = ((type(obj).__module__, type(obj).__name__), obj.serialize())