fix bug in reference counting None object (#286)

This commit is contained in:
Robert Nishihara
2016-07-22 14:15:02 -07:00
committed by Philipp Moritz
parent b68512ec7d
commit baa4b7cae3
2 changed files with 24 additions and 2 deletions
+18
View File
@@ -4,6 +4,7 @@ import numpy as np
import time
import subprocess32 as subprocess
import os
import sys
import test_functions
import ray.array.remote as ra
@@ -489,5 +490,22 @@ class PythonModeTest(unittest.TestCase):
ray.services.cleanup()
class PythonCExtensionTest(unittest.TestCase):
def testReferenceCountNone(self):
worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_worker.py")
ray.services.start_ray_local(num_workers=1, worker_path=worker_path)
# Make sure that we aren't accidentally messing up Python's reference counts.
for obj in [None, True, False]:
@ray.remote([], [int])
def f():
return sys.getrefcount(obj)
first_count = ray.get(f())
second_count = ray.get(f())
self.assertEqual(first_count, second_count)
ray.services.cleanup()
if __name__ == "__main__":
unittest.main()