mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 01:00:10 +08:00
Add type check in free and change Exception to TypeError (#4221)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -347,7 +347,7 @@ class Worker(object):
|
||||
"""
|
||||
# Make sure that the value is not an object ID.
|
||||
if isinstance(value, ObjectID):
|
||||
raise Exception(
|
||||
raise TypeError(
|
||||
"Calling 'put' on an ray.ObjectID is not allowed "
|
||||
"(similarly, returning an ray.ObjectID from a remote "
|
||||
"function is not allowed). If you really want to "
|
||||
@@ -470,7 +470,7 @@ class Worker(object):
|
||||
# Make sure that the values are object IDs.
|
||||
for object_id in object_ids:
|
||||
if not isinstance(object_id, ObjectID):
|
||||
raise Exception(
|
||||
raise TypeError(
|
||||
"Attempting to call `get` on the value {}, "
|
||||
"which is not an ray.ObjectID.".format(object_id))
|
||||
# Do an initial fetch for remote objects. We divide the fetch into
|
||||
@@ -1800,7 +1800,7 @@ def connect(info,
|
||||
driver_id = DriverID(_random_string())
|
||||
|
||||
if not isinstance(driver_id, DriverID):
|
||||
raise Exception("The type of given driver id must be DriverID.")
|
||||
raise TypeError("The type of given driver id must be DriverID.")
|
||||
|
||||
worker.worker_id = driver_id.binary()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user