emscripten-forge / recipes

Recipes to build the packages for the emscripten-forge distribution
BSD 3-Clause "New" or "Revised" License
55 stars 47 forks source link

Top level await throws `AttributeError` (IPython) #636

Closed agoose77 closed 6 months ago

agoose77 commented 1 year ago

The following key access: https://github.com/emscripten-forge/recipes/blob/1c89d7fe66ef79ac0ce2911817dd6f6299077d11/recipes/recipes_emscripten/ipython/patches/0001-Patch-asyncio-tornado.patch#L58C1-L58C1

Throws an Exception in the latest builds of Emscripten-forge. With an environment containing ipython, the following is sufficient to trigger the error.

import asyncio

await asyncio.sleep(2)

I think this is caused by a removal from pyjs: https://github.com/emscripten-forge/pyjs/blob/243074abe395bb1ac1eaa8c8741a3080d565659b/src/export_py_object.cpp#L205-L214

@martinRenou you introduced the patch for asyncio, so I wonder if you'll know how best to proceed.

martinRenou commented 1 year ago

Thank you for pinging me. Indeed I may have introduced a bug there.

Those patches used to live in xeus-python-shell but have been removed. Can you confirm that you are using the latest xeus-python-shell and latest IPython from emscripten-forge?

I will try to find the time to look into it.

We may want to test out this patch in the recipe here.

agoose77 commented 1 year ago

Yes, I'm definitely getting this from ipython on emscripten-forge :) I'm running a fresh environment for jupyterlite that pulls in the newest jupyterlite-xeus-python (0.9.4). I assume this also pulls in the core at runtime.

agoose77 commented 1 year ago

@martinRenou I had another question that not relevant for this repo, but I can't think where to open an issue:

I want to adapt a library that performs blocking IO to work with emscripten. It's my understanding that it's impossible to perform blocking requests for byte ranges, because this hangs the same event loop that JS uses. Is that correct?

DerThorsten commented 11 months ago

I think this is caused by a removal from pyjs: https://github.com/emscripten-forge/pyjs/blob/243074abe395bb1ac1eaa8c8741a3080d565659b/src/export_py_object.cpp#L205-L214

@agoose77 do you see some access to the deleted symbol? Ie __usafe_void_val_val__ or is this a guess?

DerThorsten commented 6 months ago

this was fixed in pyjs / xeus-python recently so I believe we can close this