Skip to content

Refactor Buffer class PV disconnection logic for clarity - #24

Merged
eloise-nebula merged 6 commits into
slaclab:masterfrom
kabanaty:master
Jun 18, 2026
Merged

Refactor Buffer class PV disconnection logic for clarity#24
eloise-nebula merged 6 commits into
slaclab:masterfrom
kabanaty:master

Conversation

@kabanaty

@kabanaty kabanaty commented Jun 18, 2026

Copy link
Copy Markdown

During MD on 6/17, we encountered issues with the PV and CA cache filling up after repeated scans and leading to failed PV connections. Each wire scan instantiates ~250 PV objects that persist with an automatic monitor. This automatic monitor is convenient for "normal" PVs but buffer PVs have a different use-case.

After a buffer is released, there is no guarantee that the next buffer reserved will be the same number. This makes maintaining a connection to that buffer's HST PVs pointless, because the next buffer.get() will be to a different PV, e.g., HST5 vs. HST8. The user does not need to maintain a monitor on the HST<num> PVs after the buffer is released.

The initial code was a hotfix merged in without proper review. This PR is to address the code clarity and organization and provide a venue for discussion on the topic.

@kabanaty
kabanaty requested a review from eloise-nebula June 18, 2026 17:35
Comment thread slac_timing/buffer.py Outdated
Comment on lines +274 to +275
except BaseException:
pass

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily, I just don't want to crash out if pv_obj doesn't exist or can't disconnect for some reason.

Comment thread slac_timing/buffer.py Outdated
Comment on lines +274 to +275
except BaseException:
pass

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific exception we're catching here?

Comment thread slac_timing/buffer.py Outdated
Comment on lines +287 to +288
except BaseException:
context_cache.pop(name, None)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally might be more appropriate here.

@eloise-nebula eloise-nebula left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Tyler, this looks great. Just a couple comments on exception handling.

@kabanaty

Copy link
Copy Markdown
Author

I dropped all try/except/finally logic since we're checking for existence before the loop anyways. I'm not crazy about the lack of try/except logic because I don't want scans to fail because buffer cleanup failed, but it will teach us something about CA connections.

@eloise-nebula
eloise-nebula merged commit 3f531a6 into slaclab:master Jun 18, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants