Tin mới
concurrent.futures — Launching parallel tasks
subprocess — Subprocess management
threading: Thread-based parallelism.
The concurrent.interpreters module constructs higher-level interfaces on top of the lower level _interpreters module.
How to update an extension module to support multiple interpreters.
This module does not work or is not available on WebAssembly. See WebAssembly platforms for more information.
Running in a different interpreter involves switching to it in the current thread and then calling some function. The runtime will execute the function using the current interpreter’s state. The concurrent.interpreters m
As noted earlier, interpreters do not provide any concurrency on their own. They strictly represent the isolated execution context the runtime will use in the current thread. That isolation makes them similar to processe
Communication Between Interpreters¶
In practice, multiple interpreters are useful only if we have a way to communicate between them. This usually involves some form of message passing, but can even mean sharing data in some carefully managed way.
pickle: Convert Python objects to streams of bytes and back.
Any data actually shared between interpreters loses the thread-safety provided by the GIL. There are various options for dealing with this in extension modules. However, from Python code the lack of thread-safety means o