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

Use weak reference from SessionInfo #950

Closed
wyfo opened this issue Apr 18, 2024 · 1 comment
Closed

Use weak reference from SessionInfo #950

wyfo opened this issue Apr 18, 2024 · 1 comment
Labels
new feature Something new is needed

Comments

@wyfo
Copy link
Contributor

wyfo commented Apr 18, 2024

Describe the feature

SessionInfo<'static> use a strong reference to Session. This is can be an issue because it may prevents the session to be closed by not being able to claim ownership of the Arc.

In normal languages with scoped variables, this is not really an issue, but in esoteric script dialects like Python, this is a real issue, see this example of the reworked api:

with zenoh.open(conf) as session:
    info = session.info
    print(f"zid: {info.zid()}")

The context manager exit method (closing the session) will fail, because the ownership of the session cannot be claimed – yes, even with context manager.
del info statement must be explicitly added to make it work. With weak reference into SessionInfo, that would not be an issue.

@wyfo wyfo added the new feature Something new is needed label Apr 18, 2024
@wyfo
Copy link
Contributor Author

wyfo commented Apr 25, 2024

I've changed the Python API to use a weak reference to session instead of simply wrapping the rust type, so this is not a problem anymore.
Thank you @OlivierHecart for the idea.

@wyfo wyfo closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Something new is needed
Projects
None yet
Development

No branches or pull requests

1 participant