Add type check in free and change Exception to TypeError (#4221)

This commit is contained in:
Yuhong Guo
2019-03-04 16:40:04 +08:00
committed by GitHub
parent e96e06e031
commit 5866fd7005
2 changed files with 9 additions and 3 deletions
+6
View File
@@ -35,6 +35,12 @@ def free(object_ids, local_only=False):
raise TypeError("free() expects a list of ObjectID, got {}".format(
type(object_ids)))
# Make sure that the values are object IDs.
for object_id in object_ids:
if not isinstance(object_id, ray.ObjectID):
raise TypeError("Attempting to call `free` on the value {}, "
"which is not an ray.ObjectID.".format(object_id))
worker.check_connected()
with profiling.profile("ray.free"):
if len(object_ids) == 0: