Stream: wasmtime

Topic: ✔ Thread safety of wasmtime (python)?


view this post on Zulip Christoph Brewing (Oct 17 2024 at 09:42):

Thank you guys! That all makes sense.

For now, I decided to protect the access to wasmtime with a lock. That also prevents the application from race conditions - similar as if it is run single-threaded.

My hope is that by using the lock instead of restricting the number of threads to one, the bunch of (Polars) threads does some useful work elsewhere, e.g. writing to the result file while another thread still makes use of my WASM component.

view this post on Zulip Notification Bot (Oct 17 2024 at 09:42):

Christoph Brewing has marked this topic as resolved.

view this post on Zulip Brett Cannon (Oct 17 2024 at 16:33):

Alex Crichton said:

The wasmtime-py package uses ctypes in Python which I believe means that the GIL is released whenever Wasmtime-native code is executing.

Yep, ctypes will release the GIL as the assumption is you're calling C code that doesn't have Python objects involved.


Last updated: Dec 23 2024 at 14:03 UTC