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

python: wasmedge docker image hangs when importing the socket package #96

Open
achille-roussel opened this issue Apr 25, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@achille-roussel
Copy link

Describe the bug

When importing the socket package, the program hangs and may only be interrupted by termination via a signal.

Reproduction steps

$ docker run --rm \
  -i \
  --runtime=io.containerd.wasmedge.v1 \
  --platform=wasm32/wasi \
  ghcr.io/vmware-labs/python-wasm:3.11.1-wasmedge \
  -i
Python 3.11.1 (tags/v3.11.1:a7a450f, Feb 17 2023, 11:01:02) [Clang 15.0.7 ] on wasi
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket

Expected behavior

The documentation appears to say that networking with Python is possible when using the build leveraging the WasmEdge socket API extensions. I expected to be able to import the socket package and either create a TCP client or server.

Additional context

No response

@achille-roussel achille-roussel added the bug Something isn't working label Apr 25, 2023
@assambar
Copy link
Contributor

assambar commented Apr 25, 2023

You are right! The documentation is misleading in this case. I will correct it shortly.
Here is the issue we have to track integrating WasmEdge sockets with CPython - #70

The reason we have a separate build is purely for the sake of the sock_accept method which has different signature in wasi_preview_1 and with WasmEdge.

@assambar
Copy link
Contributor

Thanks a lot for pointing this out!

@achille-roussel , on a side note - is socket support in Python something for which you have some immediate business need , or are you just experimenting?

Asking to help us prioritize. Thanks!

@achille-roussel
Copy link
Author

achille-roussel commented Apr 25, 2023

I'm exploring what currently exists in the industry for networking with WASI. The use case is implementing it in Go, and I would like to stay as close to something that already exists for interoperability between languages and runtimes.

Based on this comment it appears that wasmedge corrected their implementation of sock_accept in v0.12+ https://github.com/WasmEdge/WasmEdge/blob/master/lib/host/wasi/wasimodule.cpp#L64-L73 Maybe you won't need to ship a different build in the future :)

  // To make the socket API compatible with the old one,
  // we will duplicate all the API to V1 and V2.
  // The V1 presents the original behavior before 0.12 release.
  // On the other hand, the V2 presents the new behavior including
  // the sock_accept is following the WASI spec, some of the API
  // use a larger size for handling complex address type, e.g.
  // AF_UNIX.
  // By default, we will register V1 first, if the signatures are
  // not the same as the wasm application imported, then V2 will
  // replace instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants