我正在使用
Python 2.7版.
我有一个用C编写的Python模块扩展.
模块初始化函数PyMODINIT_FUNC initmymodule包含一些用于初始化OpenSSL库的代码.我的模块构建为共享库,并通过imp.load_dynamic加载
此模块可能会加载很多次,我无法控制它. Django和python这样做.当它加载两次然后OPENSSL_config函数调用两次.它导致进程崩溃.
我无法用C代码控制它,我无法用Python代码控制它.
imp.load_dynamic Load and initialize a module implemented as a
dynamically loadable shared library and return its module object. If
the module was already initialized, it will be initialized again.
尼斯.
Modules which do support multiple initialization set their m_size
field to a non-negative number (indicating the size of the
module-specific state). They are still recorded in the extensions
dictionary, to avoid loading shared libraries twice.
但是我应该在Python 2.7中做些什么呢?