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.
Christoph Brewing has marked this topic as resolved.
Alex Crichton said:
The
wasmtime-py
package usesctypes
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: Nov 22 2024 at 17:03 UTC