GithubHelp home page GithubHelp logo

Comments (9)

linear avatar linear commented on June 18, 2024

RUN-137 running python.wasm running a test.py script that uses requests package gets stuck in on import requests.

from wasmer.

syrusakbary avatar syrusakbary commented on June 18, 2024

Thanks for opening the issue. We'll investigate. Meanwhile, because socket support in Wasi Preview 1 (the target that Python is compiled to in the link you posted) is very unstable, I don't think it will fully work with them even if SSL is available.

We will debug to see where the halt is coming from, as that's likely an issue in Wasmer.
But meanwhile, can you try to run your program (that uses requests) in Wasmer with the Python package from the Wasmer registry: https://wasmer.io/python/python and let us know if that doesn't work for you?

$ wasmer run python/python

It may be useful to see how to run packages with dependencies based on this example: https://github.com/wasmerio/python-flask-example

from wasmer.

relcodedev avatar relcodedev commented on June 18, 2024

yes I previously ran the one from the register and the same thing occurred. It was stuck in the same place.

from wasmer.

theduke avatar theduke commented on June 18, 2024

@relcodedev you need to specify wasmer run --net to enable networking.

I don't see that in your posted CLI command.

from wasmer.

relcodedev avatar relcodedev commented on June 18, 2024

I didn't add --net because I wanted to make sure it failed. I want to test that the script did not have any network access. The other runtimes fail and give appropriate message and not get stuck.

from wasmer.

theduke avatar theduke commented on June 18, 2024

Yeah that may well be a bug.

Until we have time to investigate, you could run with RUST_LOG=wasmer_wasix=trace wasmer run ... to see a log of the syscalls, which would likely tell us where things get stuck.

from wasmer.

relcodedev avatar relcodedev commented on June 18, 2024

Ok, I retested with with wasmer run python/python and it works but not with my python.wasm file. Sorry, I thought I tested properly last time with python/python. I get the proper Not Supported message.

Using my version of the python.wasm, this is the output below.

my script has import sys and import socket. I remove import socket it works.

with import socket, these are the last ~34 lines

zipimport: zlib available

2024-04-03T15:35:31.995069Z TRACE ThreadId(01) fd_write: wasmer_wasix::syscalls::wasi::fd_write: return=Ok(Errno::success) fd=2 nwritten=28
2024-04-03T15:35:31.995104Z TRACE ThreadId(01) fd_write: wasmer_wasix::syscalls::wasi::fd_write: close time.busy=29.5ms time.idle=1.00µs fd=2 nwritten=28
2024-04-03T15:35:31.995402Z TRACE ThreadId(01) fd_fdstat_get: wasmer_wasix::syscalls::wasi::fd_fdstat_get: return=Errno::success fd=5
2024-04-03T15:35:31.995421Z TRACE ThreadId(01) fd_fdstat_get: wasmer_wasix::syscalls::wasi::fd_fdstat_get: close time.busy=21.5µs time.idle=1.60µs fd=5
2024-04-03T15:35:31.995499Z DEBUG ThreadId(01) path_open: wasmer_wasix::syscalls::wasi::path_open: return=Ok(Errno::success) dirfd=5 follow_symlinks=true path="lib/python312.zip" ret_fd=35
2024-04-03T15:35:31.995511Z DEBUG ThreadId(01) path_open: wasmer_wasix::syscalls::wasi::path_open: close time.busy=56.9µs time.idle=800ns dirfd=5 follow_symlinks=true path="lib/python312.zip" ret_fd=35
2024-04-03T15:35:31.995529Z DEBUG ThreadId(01) fd_filestat_get: wasmer_wasix::syscalls::wasi::fd_filestat_get: return=Errno::success fd=35
2024-04-03T15:35:31.995539Z DEBUG ThreadId(01) fd_filestat_get: wasmer_wasix::syscalls::wasi::fd_filestat_get: close time.busy=10.9µs time.idle=600ns fd=35
2024-04-03T15:35:31.995557Z TRACE ThreadId(01) fd_fdstat_get: wasmer_wasix::syscalls::wasi::fd_fdstat_get: return=Errno::success fd=35
2024-04-03T15:35:31.995566Z TRACE ThreadId(01) fd_fdstat_get: wasmer_wasix::syscalls::wasi::fd_fdstat_get: close time.busy=9.60µs time.idle=500ns fd=35
2024-04-03T15:35:31.995594Z TRACE ThreadId(01) fd_seek: wasmer_wasix::syscalls::wasi::fd_seek: new_offset=0 fd=35 offset=0 whence=Whence::Cur
2024-04-03T15:35:31.995604Z TRACE ThreadId(01) fd_seek: wasmer_wasix::syscalls::wasi::fd_seek: return=Ok(Errno::success) fd=35 offset=0 whence=Whence::Cur
2024-04-03T15:35:31.995613Z TRACE ThreadId(01) fd_seek: wasmer_wasix::syscalls::wasi::fd_seek: close time.busy=22.1µs time.idle=900ns fd=35 offset=0 whence=Whence::Cur
2024-04-03T15:35:31.995639Z TRACE ThreadId(01) fd_seek: wasmer_wasix::syscalls::wasi::fd_seek: new_offset=611291 fd=35 offset=611291 whence=Whence::Set
2024-04-03T15:35:31.995649Z TRACE ThreadId(01) fd_seek: wasmer_wasix::syscalls::wasi::fd_seek: return=Ok(Errno::success) fd=35 offset=611291 whence=Whence::Set
2024-04-03T15:35:31.995659Z TRACE ThreadId(01) fd_seek: wasmer_wasix::syscalls::wasi::fd_seek: close time.busy=19.6µs time.idle=600ns fd=35 offset=611291 whence=Whence::Set
2024-04-03T15:35:31.995739Z TRACE ThreadId(01) fd_read: wasmer_wasix::syscalls::wasi::fd_read: return=Ok(Errno::success) fd=35 nread=8192
2024-04-03T15:35:31.995751Z TRACE ThreadId(01) fd_read: wasmer_wasix::syscalls::wasi::fd_read: close time.busy=71.1µs time.idle=700ns fd=35 nread=8192
2024-04-03T15:35:31.995799Z TRACE ThreadId(01) fd_close: wasmer_wasix::fs: weakening file descriptor fd=35 inode=9 ref_cnt=2 pid=1 fd=35
2024-04-03T15:35:31.995812Z DEBUG ThreadId(01) fd_close: wasmer_wasix::syscalls::wasi::fd_close: return=Ok(Errno::success) pid=1 fd=35
2024-04-03T15:35:31.995822Z DEBUG ThreadId(01) fd_close: wasmer_wasix::syscalls::wasi::fd_close: close time.busy=24.0µs time.idle=800ns pid=1 fd=35

zipimport: zlib available

2024-04-03T15:35:31.996029Z TRACE ThreadId(01) fd_write: wasmer_wasix::syscalls::wasi::fd_write: return=Ok(Errno::success) fd=2 nwritten=28
2024-04-03T15:35:31.996043Z TRACE ThreadId(01) fd_write: wasmer_wasix::syscalls::wasi::fd_write: close time.busy=169µs time.idle=1.50µs fd=2 nwritten=28
import 'collections.abc' # <zipimporter object "/lib/python312.zip/collections/">
2024-04-03T15:35:31.996253Z TRACE ThreadId(01) fd_write: wasmer_wasix::syscalls::wasi::fd_write: return=Ok(Errno::success) fd=2 nwritten=82
2024-04-03T15:35:31.996266Z TRACE ThreadId(01) fd_write: wasmer_wasix::syscalls::wasi::fd_write: close time.busy=59.4µs time.idle=1.10µs fd=2 nwritten=82
import 'math' # <class '_frozen_importlib.BuiltinImporter'>
2024-04-03T15:35:31.997213Z TRACE ThreadId(01) fd_write: wasmer_wasix::syscalls::wasi::fd_write: return=Ok(Errno::success) fd=2 nwritten=60
2024-04-03T15:35:31.997228Z TRACE ThreadId(01) fd_write: wasmer_wasix::syscalls::wasi::fd_write: close time.busy=78.0µs time.idle=1.10µs fd=2 nwritten=60
import 'select' # <class '_frozen_importlib.BuiltinImporter'>
2024-04-03T15:35:31.997536Z TRACE ThreadId(01) fd_write: wasmer_wasix::syscalls::wasi::fd_write: return=Ok(Errno::success) fd=2 nwritten=62
2024-04-03T15:35:31.997550Z TRACE ThreadId(01) fd_write: wasmer_wasix::syscalls::wasi::fd_write: close time.busy=56.9µs time.idle=1.20µs fd=2 nwritten=62

from wasmer.

syrusakbary avatar syrusakbary commented on June 18, 2024

As long as things from the Wasmer registry work, we should be good to go @relcodedev .

The Python package in the registry uses WASIX instead of WASI, and as such requests/asyncio/sockets/... are fully supported.
If you have compiled your python.wasm manually without using WASIX, we can't guarantee the work (since there might be an issue on the way you compiled it).

Is there any reason for using that Python Wasm file instead of the official in the Wasmer repository (python/python)?

from wasmer.

relcodedev avatar relcodedev commented on June 18, 2024

We need to run in a locked down environment. Is there a way to pull down the python/python version to keep locally? Does wasmer store the file locally on run?

from wasmer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.