[Serve] Disable serialization for client and print helpful msg (#11181)

This commit is contained in:
Simon Mo
2020-10-07 10:50:30 -07:00
committed by GitHub
parent 91d0f41a2f
commit 68106425db
+9 -1
View File
@@ -7,7 +7,7 @@ from ray.serve.constants import (DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT,
from ray.serve.controller import ServeController
from ray.serve.handle import RayServeHandle
from ray.serve.utils import (block_until_http_ready, format_actor_name,
get_random_letters)
get_random_letters, logger)
from ray.serve.exceptions import RayServeException
from ray.serve.config import BackendConfig, ReplicaConfig, BackendMetadata
from ray.actor import ActorHandle
@@ -53,8 +53,16 @@ class Client:
def __del__(self):
if not self._detached:
logger.info("Shutting down Ray Serve because client went out of "
"scope. To prevent this, either keep a reference to "
"the client object or use serve.start(detached=True).")
self.shutdown()
def __reduce__(self):
raise RayServeException(
("Ray Serve client cannot be serialized. Please use "
"serve.connect() to get a client from within a backend."))
def shutdown(self) -> None:
"""Completely shut down the connected Serve instance.