Throw Python exception if plasma store cannot create new object. (#162)

* Propagate error messages through plasma create.

* Use custom exception types instead of exception messages.
This commit is contained in:
Robert Nishihara
2016-12-28 11:56:16 -08:00
committed by Stephanie Wang
parent 10e067e5e5
commit baf835efcd
12 changed files with 190 additions and 65 deletions
+3 -4
View File
@@ -421,12 +421,11 @@ class Worker(object):
size = size + 4096 * 4 + 8 # The last 8 bytes are for the metadata offset. This is temporary.
try:
buff = self.plasma_client.create(objectid.id(), size, bytearray(schema))
except RuntimeError as e:
if e.args != ("an object with this ID could not be created",):
raise
except plasma.plasma_object_exists_error as e:
# The object already exists in the object store, so there is no need to
# add it again. TODO(rkn): We need to compare the hashes and make sure
# that the objects are in fact the same.
# that the objects are in fact the same. We also should return an error
# code to the caller instead of printing a message.
print("This object already exists in the object store.")
return
data = np.frombuffer(buff.buffer, dtype="byte")[8:]