Skip to content
This repository was archived by the owner on Feb 14, 2024. It is now read-only.

Add xeus-python services #20

Closed

Conversation

martinRenou
Copy link
Member

Adding a service worker globally usable by all xeus-python kernels for sleeping.

Ideas for xeus-python services usage:

  • make the requests Python package work with this?
  • make the input blocking?
  • make the with open('file.txt') work with this by requesting to the browser local storage?

This should probably be upstreamed to jupyterlite so that it's usable by all kernels

@davidbrochart
Copy link

  • make the requests Python package work with this?

From this discussion it seems that it's not possible.

@martinRenou
Copy link
Member Author

Why do you say not possible?

@davidbrochart
Copy link

From what I read:

"Well, these docs make it seem like it should be possible, but pyodide's open_url() explicitly says it doesn't support binaries--I assume for a good reason.

I ran into this same issue last week trying to make a drop-in to replace the use of requests in my siphon library so that I could get some other protocol working. I came to the conclusion that async is the only option here, which I'm guessing is why we haven't seen a simple requests-replacement."

@DerThorsten
Copy link
Collaborator

@davidbrochart could you specify what kind of binaries are not working? Before reading this thread I actually tried to write a simple request replacement based on synchronous XMLHttpRequest. And it seems that for GET request most things I tried are working.
not_requests

@DerThorsten
Copy link
Collaborator

"Well, these docs make it seem like it should be possible, but pyodide's open_url() explicitly says it doesn't support binaries--I assume for a good reason.

I think the good reason is that they must assume that open_url is not only used from a worker, but also from the main thread, where blocking is not so fine. On the main thread sync XMLHttpRequest are even deprecated.

Since we always run things in a worker with xeus-python, it could be fine to XMLHttpRequest for binary data...But at the end of the day, I have not that much knowledge about js/browser stuff :)

@davidbrochart
Copy link

Thanks for clarifying @DerThorsten, great to know that when running from a worker everything works fine.

@martinRenou
Copy link
Member Author

Closing this as it's not relevant anymore. JupyterLite now provides a service worker for file access, we have a decent sleep implementation for now, and it might be better to implement a blocking input with sharedarraybuffer when it's available.

@martinRenou martinRenou deleted the xeus-python-services branch June 17, 2022 07:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants