Catch incorrect arguments to PlasmaClient constructor. (#18)

This commit is contained in:
Robert Nishihara
2016-09-14 14:21:24 -07:00
committed by Philipp Moritz
parent 72361c9b44
commit 28c19a38c9
+6
View File
@@ -31,6 +31,12 @@ class PlasmaClient(object):
addr (str): IPv4 address of plasma manager attached to the plasma store.
port (int): Port number of the plasma manager attached to the plasma store.
"""
if port is not None:
if not isinstance(port, int):
raise Exception("The 'port' argument must be an integer. The given argument has type {}.".format(type(port)))
if not 0 < port < 65536:
raise Exception("The 'port' argument must be greater than 0 and less than 65536. The given value is {}.".format(port))
plasma_client_library = os.path.join(os.path.abspath(os.path.dirname(__file__)), "../../build/plasma_client.so")
self.client = ctypes.cdll.LoadLibrary(plasma_client_library)