Register Common.error with local scheduler extension module. (#1316)

* Register Common.error with local scheduler extension module.

* Add test.
This commit is contained in:
Robert Nishihara
2017-12-13 11:55:54 -08:00
committed by Philipp Moritz
parent b6a35e0395
commit f75b51d178
3 changed files with 24 additions and 6 deletions
+2 -2
View File
@@ -4,9 +4,9 @@ from __future__ import print_function
from ray.core.src.local_scheduler.liblocal_scheduler_library import (
Task, LocalSchedulerClient, ObjectID, check_simple_value, task_from_string,
task_to_string, _config)
task_to_string, _config, common_error)
from .local_scheduler_services import start_local_scheduler
__all__ = ["Task", "LocalSchedulerClient", "ObjectID", "check_simple_value",
"task_from_string", "task_to_string", "start_local_scheduler",
"_config"]
"_config", "common_error"]
@@ -287,10 +287,10 @@ MOD_INIT(liblocal_scheduler_library) {
g_task_builder = make_task_builder();
char local_scheduler_error[] = "local_scheduler.error";
LocalSchedulerError = PyErr_NewException(local_scheduler_error, NULL, NULL);
Py_INCREF(LocalSchedulerError);
PyModule_AddObject(m, "local_scheduler_error", LocalSchedulerError);
char common_error[] = "common.error";
CommonError = PyErr_NewException(common_error, NULL, NULL);
Py_INCREF(CommonError);
PyModule_AddObject(m, "common_error", CommonError);
Py_INCREF(&PyRayConfigType);
PyModule_AddObject(m, "RayConfig", (PyObject *) &PyRayConfigType);
+18
View File
@@ -284,6 +284,24 @@ class SerializationTest(unittest.TestCase):
ray.worker.cleanup()
def testPuttingObjectThatClosesOverObjectID(self):
# This test is here to prevent a regression of
# https://github.com/ray-project/ray/issues/1317.
ray.init(num_workers=0)
class Foo(object):
def __init__(self):
self.val = ray.put(0)
def method(self):
f
f = Foo()
with self.assertRaises(ray.local_scheduler.common_error):
ray.put(f)
ray.worker.cleanup()
class WorkerTest(unittest.TestCase):
def testPythonWorkers(self):