mirror of
https://github.com/wassname/ray.git
synced 2026-07-02 21:05:07 +08:00
preparation to deallocate objects properly
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user