-
Notifications
You must be signed in to change notification settings - Fork 320
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
Use weakref finalize to close visa connections #5341
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## master #5341 +/- ##
==========================================
+ Coverage 67.62% 67.63% +0.01%
==========================================
Files 360 360
Lines 30059 30069 +10
==========================================
+ Hits 20328 20338 +10
Misses 9731 9731 |
astafan8
reviewed
Sep 4, 2023
astafan8
approved these changes
Sep 5, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and a newsfragment? :)
jenshnielsen
force-pushed
the
shutdown_visa
branch
from
September 11, 2023 18:38
7e2c2f5
to
69337f1
Compare
astafan8
approved these changes
Sep 12, 2023
Co-authored-by: Mikhail Astafev <[email protected]>
jenshnielsen
force-pushed
the
shutdown_visa
branch
from
September 12, 2023 11:54
71955cd
to
a033320
Compare
This was referenced Oct 13, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partial fix for #3774 it's tricky to do this generally since the finalizer cannot take a reference to the instrument it self and therefore also not a method on this such as
self.close
.For visa instruments this is possible to implement since we only need a reference to the visa_handle to close the connection. This could also be implemented more generally if we created a handle/closer class on all instruments.
This also adds tests that confirms that visa instruments are closed once the instrument is out of scope and gc'ed.
Closes #5356 by closing the resource_manager in close if the backend is sim. Since this only applies to simulated instruments we don't add it to the finalizer but assume as always that a test must cleanup after it self.