| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Use standard atexit handler to remove Python-extended prototype
objects from C++ registry. Ensure cleanup is truly executed
instead of relying on garbage collector to call `__del__`.
This prevents the following error message on Python exit
Fatal Python error: PyThreadState_Get: the function must be called
with the GIL held, but the GIL is released (the current Python
thread state is NULL)
Can as well test with the builtin complex here.
|
Thank you so much. |
Sorry, something went wrong.
|
@Sparks29032 - are you still getting the GIL error? Here is how I check on my side on Debian Linux in a fresh conda environment for Python 3.10 - # create fresh conda environment "tgil" with Python 3.10
conda create -n tgil "python==3.10"
conda activate tgil
conda install boost gsl numpy scons setuptools
pip install diffpy.structure periodictable pycifrw
# tell c++ compiler to use tgil libraries
P="$(conda info --json | grep default_prefix | cut -d\" -f4)"
export CPATH="$P/include"
export LIBRARY_PATH="$P/lib"
export LDFLAGS="-Wl,-rpath,$P/lib"
# install libdiffpy to the tgil
mkdir /tmp/repos
cd /tmp/repos
git clone https://github.com/diffpy/libdiffpy.git
cd libdiffpy
git checkout main
scons -j4 prefix=$P install
# build srreal in development mode and have Python use repo sources
cd /tmp/repos
git clone https://github.com/diffpy/diffpy.srreal.git
cd diffpy.srreal
git checkout main
export PYTHONPATH="${PWD}/src:${PYTHONPATH}"
scons -j4 develop
# these commands give "Fatal Python error ... GIL is released"
python -m diffpy.srreal.tests.run
python -c "import diffpy.srreal.atomradiitable"
# the same commands show no GIL error at this PR
git fetch origin refs/pull/28/head:pr28
git checkout pr28
python -m diffpy.srreal.tests.run
python -c "import diffpy.srreal.atomradiitable" |
Sorry, something went wrong.
|
@pavoljuhas Nope, this fixed it. Tested on my Ubuntu (local) and had conda-forge build and test (importing diffpy.srreal.srreal_ext and diffpy.srreal.atomradiitable) for OSX. Windows tests are still skipped. Failures on the conda-forge are due to use of numpy.distutils and occur only for Python 3.12. Once we merge this PR, let's fix that and do a release! Again, thank you so much! |
Sorry, something went wrong.
|
Thanks @pavoljuhas @Sparks29032 I feel like it is my birthday and Christmas all rolled in one! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Use atexit for cleanup of Python-extended prototypes
Use standard atexit handler to remove Python-extended prototype
objects from C++ registry. Ensure cleanup is truly executed
instead of relying on garbage collector to call __del__.
This prevents the following error message on Python exit