Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
Closes: #49451
Signed-off-by: Chi-Sheng Liu <[email protected]>
  • Loading branch information
MortalHappiness committed Jan 17, 2025
1 parent 697e22c commit a1fa8ac
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions python/ray/tests/test_actor_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,39 @@ def verify():
wait_for_condition(verify)


def test_exit_actor_async_actor_nested_task(shutdown_only, tmp_path):
async_temp_file = tmp_path / "async_actor.log"
async_temp_file.touch()

@ray.remote
class AsyncActor:
def __init__(self):
def f():
print("atexit handler")
with open(async_temp_file, "w") as f:
f.write("Async Actor\n")

atexit.register(f)

async def start_exit_task(self):
asyncio.create_task(self.exit())

async def exit(self):
exit_actor()

a = AsyncActor.remote()
ray.get(a.__ray_ready__.remote())
with pytest.raises(ray.exceptions.RayActorError):
ray.get(a.start_exit_task.remote())

def verify():
with open(async_temp_file) as f:
assert f.readlines() == ["Async Actor\n"]
return True

wait_for_condition(verify)


def test_exit_actor_queued(shutdown_only):
"""Verify after exit_actor is called the queued tasks won't execute."""

Expand Down

0 comments on commit a1fa8ac

Please sign in to comment.