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

Metadata handling for not-yet-connected signals #617

Open
ZLLentz opened this issue Jun 25, 2024 · 2 comments
Open

Metadata handling for not-yet-connected signals #617

ZLLentz opened this issue Jun 25, 2024 · 2 comments

Comments

@ZLLentz
Copy link
Member

ZLLentz commented Jun 25, 2024

Expected Behavior

In all cases, the signal metadata should be communicated to the consumers of the signals prior to sending the values. This ensures the widget can prepare proper context for the data coming in.

Current Behavior

In cases where the signal is connecting for the first time after listeners have already been added, it's possible for the value callback to fire prior to the metadata callback.

Possible Solution

Add some sort of blocking/deferring mechanism, holding back all value callbacks until the first valid metadata callback is received.

Steps to Reproduce (for bugs)

  1. Create an EpicsSignal with enum strings
  2. Use it right away in a PyDMComboboxWidget prior to it being fully connected

This may be a race condition and may not happen every time.

Context

Discovered while testing #616

Your Environment

typhos branch from the linked PR with the following critical package versions from pydm (plus my ophyd version):

  • python 3.9.18
  • numpy 1.24.4
  • PyQt 5.15.9
  • Qt 5.15.8
  • PyQtGraph 0.13.3
  • ophyd 1.7.0
@tangkong
Copy link
Contributor

I fear yet another callback queue that piles up while waiting for some EPICS connection to establish 💀

This is probably the right path though, I might just suggest we have a timeout on how long those value callbacks can dwell. When the value callback fires first, is the state unrecoverable? Or could we refresh the view and get everything working again?

@ZLLentz ZLLentz changed the title Metadata handling for non-yet-connected signals Metadata handling for not-yet-connected signals Jun 25, 2024
@ZLLentz
Copy link
Member Author

ZLLentz commented Jun 25, 2024

Yeah, we could easily get into trouble here...
In some cases this doesn't matter at all, most of the time when it matters it results in some annoying terminal spam. I'm not sure if this is ever fatal.
It's pretty minor as far as I can tell.

Rather than hold up the callback queue, I'd do something like:

  • Value cb comes in, but no meta yet
  • Cache the value cb and don't emit
  • More value cbs come in before metadata? Just overwrite the cached value
  • First metadata comes through? Emit the cached value afterwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants