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

Query context manager #461

Merged
merged 4 commits into from
Mar 6, 2025

Conversation

wyfo
Copy link
Contributor

@wyfo wyfo commented Feb 28, 2025

Based on #460
Fixes #459

wyfo added 2 commits February 28, 2025 10:06
Only the `IntoPython` bound is important, the rest was there to
reinforce the typing, but it's not needed at all, and it prevented
to use objects not implementing `IntoRust` (which will be the case
when `Query` will use `option_wrapper`)
Copy link
Contributor

PR missing one of the required labels: {'enhancement', 'bug', 'internal', 'documentation', 'breaking-change', 'new feature', 'dependencies'}

@wyfo wyfo added enhancement Things could work better new feature Something new is needed api sync Synchronize API with other bindings labels Feb 28, 2025
@@ -552,6 +554,7 @@ class Query:
By default, queries only accept replies whose key expression intersects with the query's. Unless the query has enabled disjoint replies (you can check this through Query::accepts_replies), replying on a disjoint key expression will result in an error when resolving the reply.
"""

def drop(self): ...
Copy link
Contributor

Choose a reason for hiding this comment

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

I think drop requires a documentation, with a good explanation, why it is needed. I would also stress that user MUST call it once he provided all the replies (or use context) since I'm not sure we can entirely trust python to call the destructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it does, give me a few minutes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably also mention in reply, reply_del and reply_err methods, that multiple replies are possible and that they are only sent once drop is called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the docstring (I didn't have the necessary inspiration earlier).

The documentation of reply_xxx are aligned on the Rust API. Updating them is not the subject of this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but in rust drop happens automatically, and here we need to do it manually, so I would rather update it, to avoid false bug reports from users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What you said is not exact. The responses are sent directly, it's just the ResponseFinal message that is sent when the query is dropped. And because default consolidation is latest, get waits for the ResponseFinal to return the responses.
By the way, if you don't reply anything, but don't drop the query, get will still hang. So there is nothing about reply_xxx methods there.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, there is nothing about reply_xxx to it, but these kind of methods are likely to be used by user, so he is more likely to see the docs and learn that it is mandatory to call drop, otherwise I do not see how to let user know that he needs to call drop if he is unaware of its existence.

@wyfo wyfo requested a review from DenisBiryukov91 February 28, 2025 10:28
@milyin milyin merged commit 625e32e into eclipse-zenoh:main Mar 6, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api sync Synchronize API with other bindings enhancement Things could work better new feature Something new is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python recv on queryable can't be used to reply
3 participants