-
Notifications
You must be signed in to change notification settings - Fork 42
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
Python recv on queryable can't be used to reply #459
Comments
I can reproduce the bug. The strange thing is that if I do another query, on a parallel process, the response to the second query goes to the first one. I'm investigating more. EDIT: actually, the query times out, but the response arrives just after the timeout. |
Ok, we have found the explanation: a query can have many replies, and ends with a response-final message, which is automatically sent when the query object is finalized. It works well in languages like Rust or C++, but Python scoping rules are completely different, and the listen = session.declare_queryable("**")
while True:
with listen.recv() as query:
query.reply(query.key_expr, "Hi") I will open a PR to add the context manager. P.S. This workaround also works, but a context manager is better listen = session.declare_queryable("**")
while True:
query = listen.recv()
query.reply(query.key_expr, "Hi")
query = None # force the previous value to be finalized |
#461 adds context manager to query, and updates |
I can confirm this PR fixes the issue! |
Describe the bug
The queryable example uses a callback + blocking loop to handle messages. This works file but is an odd interface for a listener, requiring an arbitrary sleep state that can otherwise be replaced by a blocking recv:
This is far more ergonomic interface IMO, however, the
query.reply
never makes it to the caller. Theget
call from any client times out. All of the examples use the callback form so I don't have a working example to go by.Am I missing something in the setup/use of the
listen.recv()
interface?To reproduce
declare_queryable
(see above)query.reply
but the caller does not receive the reply - it times outSystem info
The text was updated successfully, but these errors were encountered: