Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rationalise interface for *wait_for_value* #461

Open
coretl opened this issue Jul 16, 2024 · 1 comment · May be fixed by #652
Open

Rationalise interface for *wait_for_value* #461

coretl opened this issue Jul 16, 2024 · 1 comment · May be fixed by #652
Assignees
Milestone

Comments

@coretl
Copy link
Collaborator

coretl commented Jul 16, 2024

After discussions surrounding #453 and #447 I suggest we make the following changes to the following helpers for signal operations:

  • Stop returning the status from set_and_wait_for_*value and instead await it, using timeout for it rather than a separate status_timeout
  • Update all the areaDetector usages from:
arm_status = await set_and_wait_for_value(self.acquire, True)
...
await arm_status

to

arm_status = self.acquire.set(True)
await wait_for_value(self.acquire, True)
...
await arm_status
  • Support using a match function in set_and_wait_for_value and set_and_wait_for_other_value

That would make the interface:

async def observe_value(
    signal: SignalR[T],
    timeout: float | None = None,
    done_status: Status | None = None) -> AsyncGenerator[T, None]:
    ...

@override
async def observe_signals_value(signal1: SignalR[T], signalR[T2]) -> AsyncGenerator[Tuple[SignalR[T], T] | Tuple[SignalR[T2], T2]]:  # expand this for all combinations like asyncio.gather type stub does
    ...

async def observe_signals_value(
    *signals: SignalR[T],
    timeout: float | None = None,
    done_status: Status | None = None) -> AsyncGenerator[Tuple[SignalR[T], T], None]:
    ...

async def wait_for_value(
    signal: SignalR[T], 
    match_value: T | Callable[[T], bool], 
    timeout: Optional[float] = DEFAULT_TIMEOUT) -> None:
    ...

async def set_and_wait_for_value(
    signal: SignalRW[T], 
    value: T, 
    match_value: T | Callable[[T], bool] | None = None, 
    timeout: Optional[float] = DEFAULT_TIMEOUT) -> None:
    ...

async def set_and_wait_for_other_value(
    signal: SignalW[T],
    value: T, 
    match_signal: SignalR[S],
    match_value: S | Callable[[S], bool], 
    timeout: Optional[float] = DEFAULT_TIMEOUT) -> None:
    ...
@coretl
Copy link
Collaborator Author

coretl commented Jul 25, 2024

And also #402

@ZohebShaikh ZohebShaikh self-assigned this Sep 12, 2024
@ZohebShaikh ZohebShaikh linked a pull request Sep 17, 2024 that will close this issue
@ZohebShaikh ZohebShaikh linked a pull request Nov 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants