mirror of
https://github.com/wassname/ray.git
synced 2026-08-12 12:20:11 +08:00
fix bug in reference counting None object (#286)
This commit is contained in:
committed by
Philipp Moritz
parent
b68512ec7d
commit
baa4b7cae3
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user