Ref count objects created with ray.put (#5590)

* wip

* add weakref option

* tune util

* test ref

* doc

* fix tests
This commit is contained in:
Eric Liang
2019-08-30 16:43:23 -07:00
committed by GitHub
parent 93e103135b
commit bea43c85b1
6 changed files with 77 additions and 23 deletions
+6 -17
View File
@@ -2,7 +2,6 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import base64
import copy
import logging
import threading
@@ -99,27 +98,17 @@ class UtilMonitor(Thread):
def pin_in_object_store(obj):
"""Pin an object in the object store.
"""Deprecated, use ray.put(value, weakref=False) instead."""
It will be available as long as the pinning process is alive. The pinned
object can be retrieved by calling get_pinned_object on the identifier
returned by this call.
"""
obj_id = ray.put(_to_pinnable(obj))
_pinned_objects.append(ray.get(obj_id))
return "{}{}".format(PINNED_OBJECT_PREFIX,
base64.b64encode(obj_id.binary()).decode("utf-8"))
obj_id = ray.put(obj, weakref=False)
_pinned_objects.append(obj_id)
return obj_id
def get_pinned_object(pinned_id):
"""Retrieve a pinned object from the object store."""
"""Deprecated."""
from ray import ObjectID
return _from_pinnable(
ray.get(
ObjectID(base64.b64decode(pinned_id[len(PINNED_OBJECT_PREFIX):]))))
return ray.get(pinned_id)
class warn_if_slow(object):