Skip to content

[serve] serve.get_deployment from within a deployment fails after 1k calls #18980

@edoakes

Description

@edoakes

Search before asking

  • I searched the issues and found no similar issues.

Ray Component

Ray Serve

What happened + What you expected to happen

Doesn't hang

Reproduction script

# -*- coding: utf-8 -*-
import asyncio
import logging
import ray
from ray import serve
ray.shutdown()
ray.init(namespace="serve")
client = serve.start(http_options={"host": "0.0.0.0", "port": 5001}, detached=True)  # Start the Ray Serve instance.
@serve.deployment(name="child", version='v1', num_replicas=1,
                  ray_actor_options={"num_gpus": 0}, route_prefix="/child")
class Child:
    def __init__(self, name: str):
        self.name = name
    def say_hi(self):
        print(f"Hi {self.name}!")

@serve.deployment(name="father", version='v1', num_replicas=1,
                  ray_actor_options={"num_gpus": 0}, route_prefix="/father")
class Father:
    def __init__(self, name: str):
        Child.options(
            name="child_1",
            ray_actor_options={"num_gpus": 0},
            route_prefix="/child/1"
        ).deploy(name)
    async def say_hi(self):
        self._logger = logging.getLogger('ray')
        self._logger.setLevel(logging.DEBUG)
        self._logger.debug("Get dplmnt")
        dplmnt = serve.get_deployment("child_1")
        self._logger.debug("Get handle")
        child_handle = dplmnt.get_handle(sync=False)
        self._logger.debug("Run hi")
        await child_handle.say_hi.remote()
        self._logger.debug("Exit")

async def run_app():
    Father.options(
        name="father_1",
        ray_actor_options={"num_gpus": 0},
        route_prefix="/father/1"
    ).deploy("John")
    it = 0
    while True:
        print("GET DEPLOYMENT")
        example_handle = serve.get_deployment("father_1").get_handle(sync=False)
        print("MAKE CALL")
        await (await example_handle.say_hi.remote())
        it = it + 1
        print(it)
if __name__ == '__main__':
    asyncio.run(run_app())

Anything else

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

Labels

P1Issue that should be fixed within a few weeksbugSomething that is supposed to be working; but isn'tserveRay Serve Related Issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions