[Serve] Unify test synchronization patterns using shared actor primitives#62191
Conversation
There was a problem hiding this comment.
Code Review
This pull request centralizes test utility actors—Barrier, Accumulator, and SharedFlag—into ray/serve/_private/test_utils.py and refactors several test suites to use these shared components, replacing local actor definitions and file-based synchronization. The review feedback identifies a missing asyncio import in the utility file that would cause a runtime error and suggests adding comprehensive type hints to the new classes to improve code consistency and clarity.
| def __init__(self, n: int): | ||
| self._n = n | ||
| self._count = 0 | ||
| self._event = asyncio.Event() |
| self._count = 0 | ||
| self._event = asyncio.Event() | ||
|
|
||
| async def wait(self): |
| def __init__(self): | ||
| self._items = [] | ||
|
|
||
| def add(self, item): |
| def add(self, item): | ||
| self._items.append(item) | ||
|
|
||
| def get(self) -> list: |
| def get(self) -> list: | ||
| return list(self._items) | ||
|
|
||
| def set_once(self, item) -> bool: |
| return True | ||
| return False | ||
|
|
||
| def get_first(self): |
There was a problem hiding this comment.
Please add a return type hint to this method for consistency. Based on the docstring, Optional[Any] would be appropriate. Note that this and other type hint suggestions for this class will require importing Any and Optional from typing.
| def get_first(self): | |
| def get_first(self) -> Optional[Any]: |
| def __init__(self): | ||
| self._value = False | ||
|
|
||
| def set(self): |
| def set(self): | ||
| self._value = True | ||
|
|
||
| def clear(self): |
d203441 to
b329778
Compare
…ives Signed-off-by: win5923 <ken89@kimo.com>
b329778 to
9ed8b17
Compare
abrarsheikh
left a comment
There was a problem hiding this comment.
this is a solid refactor, tysm
Description
Add reusable sync primitives to serve test_utils and migrate inline/file-based sync patterns to use them.
Related issues
Closes #61387
Additional information