Things to check first
Feature description
I wonder if it would make sense for AnyIO functions that use threading in the background gets fallback to the single-threaded version when threading is not available.
For example, anyio.open_file currently uses aynio.to_thread.run_sync internally, and using it in threading-less environment such as WebAssembly fails with can't start new thread error.
Use case
I maintain Pyodide + WebAssembly/Emscripten platform in CPython. In WebAssembly environment, often threading is not available and codes that use threading runs into a runtime error.
Users of startlette and FastAPI were having issues porting their application to WebAssembly, as codes such as anyio.open_file or anyio.to_thread.run_sync requires threading support in the runtime environment.
Originally, I was discussing this issue in starlette (Kludex/starlette#3284), but I was wondering if this can be solved in AnyIO side, by providing threading-less fallbacks of those functions.
Of course, I understand that running everything including the I/O functions in the same thread means it will degrade the performance. But it would help users port their existing codes that use AnyIO without modification.
Things to check first
Feature description
I wonder if it would make sense for AnyIO functions that use threading in the background gets fallback to the single-threaded version when threading is not available.
For example,
anyio.open_filecurrently usesaynio.to_thread.run_syncinternally, and using it in threading-less environment such as WebAssembly fails withcan't start new threaderror.Use case
I maintain Pyodide + WebAssembly/Emscripten platform in CPython. In WebAssembly environment, often threading is not available and codes that use threading runs into a runtime error.
Users of startlette and FastAPI were having issues porting their application to WebAssembly, as codes such as
anyio.open_fileoranyio.to_thread.run_syncrequires threading support in the runtime environment.Originally, I was discussing this issue in starlette (Kludex/starlette#3284), but I was wondering if this can be solved in AnyIO side, by providing threading-less fallbacks of those functions.
Of course, I understand that running everything including the I/O functions in the same thread means it will degrade the performance. But it would help users port their existing codes that use AnyIO without modification.