Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork320
Multi-phase module initialization implemented#505
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
In#442, it was discussed how to use sub-interpreters to achieve true parallelism using python 3.12. In python 3.14 sub-interpreters are exposed to python code through a new moduleconcurrent. Interpreters. There interpreters are isolated environments with their own GIL that can run in parallel. There are still serious limitations and one of them relates to what modules can be imported. The modules need to supportmulti-phase initialization to be able to be used. with such interpreters. Support for creating extension modules with multi-phase initialization has been added to P4D. The demoDemoModule andRTTIModule projects have been updated to showcase this new feature. There are quite a few internal changes, but the only public change is a two new properties for TPythonModule: TMultIntperpretersSupport = (mmiSupported, mmiNotSupported, mmiPerInterpreterGIL);publicproperty IsExtensionModule: Boolean read FIsExtensionModule write FIsExtensionModule;publishedproperty MultInterpretersSupport: TMultIntperpretersSupport read FMultInterpretersSupport write FMultInterpretersSupport; By default P4D extension modules support sub-interpreters but not those with their own GIL. When you create an extension module, you will need to set MultInterpretersSupport to mmiPerInterpreterGIL to support the new interpreters module. You can use the two demo modules as a guide. InDemoModule you will also find a python test fileInterpreterExecutor.py that shows how to use the newInterpreterPoolEecutor with the P4D extension module. Note that you need to use python 3.14 for running this demo. Note that the old way of creating extension modules still works. But these extension modules are not compatible with sub-interpreters. |
BetaWas this translation helpful?Give feedback.