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

Turn comm interface into a separate package #21

Closed
saraedum opened this issue Oct 5, 2021 · 2 comments
Closed

Turn comm interface into a separate package #21

saraedum opened this issue Oct 5, 2021 · 2 comments

Comments

@saraedum
Copy link
Owner

saraedum commented Oct 5, 2021

So we can use it to solve flatsurf/ipyvue-flatsurf#35.

Currently, CommWidget provides basic communication in both directions:

  • A widget inheriting from CommWidget can send messages to the clients (for client in self._clients: client.send().)
  • A widget inheriting from CommWidget can receive messages which call back into its list of self._commands.

There are some problems with this approach:

  • A message from the server to the client waits for an ACK to unblock the communication channel. This is a good idea for the time-series application but in other circumstances we do not want this. Instead we want messages without a return value and messages with an asynchronous return value (that's what the ACK is currently.)
  • A message from the client to the server does not allow any ACK or return value yet.
  • Sending a message from the client to the server is not exposed in the Vue component exported by comm.js yet.

The interface we would like to see (on the Python side.):

class Client:
  def send(self, data): ...
  async def query(self, data): ...

And the same on the JavaScript side.

A Basic Use Case

Let's suppose that we want to query the client for a half edge, i.e., the user should click on one and that is returned to the server.

We cannot send that query to all clients as is, since we would have to cancel all these queries once a click happened in one frontend. So instead, we need to perform this query with a cancellation token that is somehow hidden away on the client. Then the server can invoke this cancellation token once any of the clients responds. This means that CommWidget can implement send as for client in clients: send but needs to implement query differently to supporte:

requests = self.query(...)
await any of requests
for request in requests: request.cancel()
@saraedum
Copy link
Owner Author

This is now https://github.com/flatsurf/ipyvue-async.

@saraedum
Copy link
Owner Author

We are not using that package yet here. However, that package is now part of ipyμvue. See #36.

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

1 participant