sagemathinc / cowasm

CoWasm: Collaborative WebAssembly for Servers and Browsers. Built using Zig. Supports Python with extension modules, including numpy.
https://cowasm.org
BSD 3-Clause "New" or "Revised" License
488 stars 23 forks source link

support time.sleep properly #5

Closed williamstein closed 2 years ago

williamstein commented 2 years ago

In Pyodide doing import time; time.sleep(10) just silently does nothing right now. See https://github.com/pyodide/pyodide/issues/2354 for their discussion.

I've seen some other python wasm shell somewhere online that just spun the cpu 100% for approx 10 seconds.

On python-wasm here it gives an oserror.

The solution for python-wasm is just to properly implement whatever select system call is required, which should be completely straightforward given our model.

williamstein commented 2 years ago
~/python-wasm$ bin/python-wasm
Welcome to Node.js v16.13.0.
Type ".help" for more information.
> Python 3.11.0b3 (main, Jul 14 2022, 22:22:40) [Clang 13.0.1 (git@github.com:ziglang/zig-bootstrap.git 623481199fe17f4311cbdbbf on wasi
Type "help", "copyright", "credits" or "license" for more information.
>>> import time; time.sleep(10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 58] Not supported
williamstein commented 2 years ago

See also https://github.com/pyodide/pyodide/issues/97