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

How to poll an AsyncResult without blocking? #540

Open
patrickkidd opened this issue Jul 26, 2023 · 3 comments
Open

How to poll an AsyncResult without blocking? #540

patrickkidd opened this issue Jul 26, 2023 · 3 comments

Comments

@patrickkidd
Copy link

Describe the issue briefly here, including:

  • Expected result: Should be able to access AsyncResult.ready without blocking until remote call has completed.
  • Actual result: if async_result.ready: blocks until remote call has completed. I am unable to find the code containing the blocking call. The AsyncResult.ready implementation shows no blocking calls, yet stepping into that method from my code somehow blocks before entering it.

Steps to reproduce:

asleep = rpyc.async_(conn.modules.time.sleep)
result = asleep(5)
assert result.ready == False # This assertion fails because it blocks until the sleep completes 5 seconds after the previous line.
Environment
  • rpyc version: 5.3.0
  • python version: 3.9.13
  • operating system: Linux/Ubuntu
Minimal example

See above

@patrickkidd patrickkidd changed the title How to poll an async result without blocking? How to poll an AsyncResult without blocking? Jul 26, 2023
@patrickkidd
Copy link
Author

patrickkidd commented Jul 27, 2023

Is it only possible to execute a single async call at a time? Maybe is this limited by the single python thread on the remote side? The use case here is to be able to run multiple remote method calls in parallel, ideally using the same objects. So I suppose threads.

@patrickkidd
Copy link
Author

The only way I could figure out a truly multi-call async solution to this was to:

  • Create a threaded N-workers pool model on the server side, and a rpyc.BgServingThread
  • Pass a client-side callback to each call to the server and return a custom promise type.
  • Wrap the client's callback with rpyc.async_(...) on the server before calling it
  • Mark the promise completed and raise any remote exceptions in the promise's handler.

I'm still writing custom code for every server function call but I don't know how else to do it.

@eevleevs
Copy link

eevleevs commented Jul 1, 2024

Same here, I ended up batching the calls, seemed simpler. Can somebody with insight explain the limitation?

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

No branches or pull requests

2 participants