Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG read_pdbstr cause program to sleep forever #436

Open
shaoqx opened this issue Feb 22, 2025 · 1 comment
Open

BUG read_pdbstr cause program to sleep forever #436

shaoqx opened this issue Feb 22, 2025 · 1 comment

Comments

@shaoqx
Copy link

shaoqx commented Feb 22, 2025

Describe the bug

Yesterday I found my calculation was not started after 11 hours.
I spend a whole day trace down the problem and found it is caused by cmd.read_pdbstr from a pymol2.PyMOL() session, which use to load PDB string into a pymol session in my Python script.
I then engineered a minimum reproduction of the bug in a simple script. I also found this bug does not exist in a specific pymol version I installed from a place I dont remember. (not the one in this repo) See reproduction below.

To Reproduce

Steps to reproduce the behavior:

  1. create a new conda environment
  2. run conda install pymol-open-source -c conda-forge (This installed version=3.1.0 build=py39he07333a_0 on my machine)
  3. run this script:
import multiprocessing
import pymol2

def grow_each_window(args):
    print("start")
    call_read_pdbstr()
    print("pass")

def call_read_pdbstr():
    pms = pymol2.PyMOL()
    pms.start()
    pdb_str = "ATOM      1  N   ASP A   1      45.117  64.639  61.562  1.00  0.00"
    pms.cmd.read_pdbstr(pdb_str, "obj1")
    pms.stop()

call_read_pdbstr()
with multiprocessing.Pool(processes=4) as pool:
    pool.map(grow_each_window, range(3))
  1. You will see the script stuck after printing start and never print out pass

Analysis

I made several experiment that removes the forever sleep

  1. comment out line 16 in the script, that is, not calling read_pdbstr() before the Pool.
    This will instantly print the "pass" out
  2. Use another environment in my machine.
    lt also instantly print the "pass" out?!
    In that environment, if I run conda list pymol, I got:
# Name                    Version                   Build  Channel
pymol                     2.5.4            py39he7683a9_0    schrodinger
pymol-bundle              2.5.3                         0    schrodinger
pymol-web-examples        2.4                           1    schrodinger

For now I failed in all attempts reproducing this environment lol.

Analyzing the sleep process with pid shows that it is waiting for a lock

$ ps -o stat,wchan:40,pid,cmd -p 29735
STAT WCHAN                                       PID CMD
S+   futex_wait_queue_me                       29735 python reproduce_bug.py

Environment

  • PyMOL Version: 3.1.0 build=py39he07333a_0
  • PyMOL Source: conda pymol-open-source
  • Operating System: Linux CentOS
  • If you are using a conda environment, please supply your conda list
click to see full list
# Name                    Version                   Build  Channel                                                  
_libgcc_mutex             0.1                 conda_forge    conda-forge                                            
_openmp_mutex             4.5                       2_gnu    conda-forge                                            
alsa-lib                  1.2.13               hb9d3cd8_0    conda-forge                                            
attr                      2.5.1                h166bdaf_1    conda-forge                                            
blosc                     1.21.6               he440d0b_1    conda-forge
bzip2                     1.0.8                h4bc722e_7    conda-forge
c-ares                    1.34.4               hb9d3cd8_0    conda-forge
ca-certificates           2025.1.31            hbcca054_0    conda-forge
cairo                     1.18.2               h3394656_1    conda-forge
cyrus-sasl                2.1.27               h54b06d7_7    conda-forge
dbus                      1.13.6               h5008d03_3    conda-forge
expat                     2.6.4                h5888daf_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 h77eed37_3    conda-forge
fontconfig                2.15.0               h7e30c49_1    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freetype                  2.12.1               h267a509_2    conda-forge
gettext                   0.23.1               h5888daf_0    conda-forge
gettext-tools             0.23.1               h5888daf_0    conda-forge
glew                      2.1.0                h9c3ff4c_2    conda-forge
glib                      2.82.2               h07242d1_1    conda-forge
glib-tools                2.82.2               h4833e2c_1    conda-forge
glm                       0.9.9.8              h00ab1b0_0    conda-forge
graphite2                 1.3.13            h59595ed_1003    conda-forge
gst-plugins-base          1.24.7               h0a52356_0    conda-forge
gstreamer                 1.24.7               hf3bb09a_0    conda-forge
harfbuzz                  10.3.0               h76408a6_0    conda-forge
hdf4                      4.2.15               h2a13503_7    conda-forge
hdf5                      1.14.4          nompi_h2d575fe_105    conda-forge
icu                       75.1                 he02047a_0    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
krb5                      1.21.3               h659f571_0    conda-forge
lame                      3.100             h166bdaf_1003    conda-forge
ld_impl_linux-64          2.40                 h12ee557_0  
libaec                    1.1.3                h59595ed_0    conda-forge
libasprintf               0.23.1               h8e693c7_0    conda-forge
libasprintf-devel         0.23.1               h8e693c7_0    conda-forge
libblas                   3.9.0           31_h59b9bed_openblas    conda-forge
libcap                    2.71                 h39aace5_0    conda-forge
libcblas                  3.9.0           31_he106b2a_openblas    conda-forge
libclang-cpp19.1          19.1.7          default_hb5137d0_1    conda-forge
libclang13                19.1.7          default_h9c6a7e4_1    conda-forge
libcups                   2.3.3                h4637d8d_4    conda-forge
libcurl                   8.12.1               h332b0f4_0    conda-forge
libdrm                    2.4.124              hb9d3cd8_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libegl                    1.7.0                ha4b6fd6_2    conda-forge
libev                     4.33                 hd590300_2    conda-forge
libevent                  2.1.12               hf998b51_1    conda-forge
libexpat                  2.6.4                h5888daf_0    conda-forge
libffi                    3.4.4                h6a678d5_1  
libflac                   1.4.3                h59595ed_0    conda-forge
libgcc                    14.2.0               h77fa898_1    conda-forge
libgcc-ng                 14.2.0               h69a702a_1    conda-forge
libgcrypt-lib             1.11.0               hb9d3cd8_2    conda-forge
libgettextpo              0.23.1               h5888daf_0    conda-forge
libgettextpo-devel        0.23.1               h5888daf_0    conda-forge
libgfortran               14.2.0               h69a702a_1    conda-forge
libgfortran5              14.2.0               hd5240d6_1    conda-forge
libgl                     1.7.0                ha4b6fd6_2    conda-forge
libglib                   2.82.2               h2ff4ddf_1    conda-forge
libglu                    9.0.3                h03adeef_0    conda-forge
libglvnd                  1.7.0                ha4b6fd6_2    conda-forge
libglx                    1.7.0                ha4b6fd6_2    conda-forge
libgomp                   14.2.0               h77fa898_1    conda-forge
libgpg-error              1.51                 hbd13f7d_1    conda-forge
libiconv                  1.18                 h4ce23a2_1    conda-forge
libjpeg-turbo             3.0.0                hd590300_1    conda-forge
liblapack                 3.9.0           31_h7ac8fdf_openblas    conda-forge
libllvm19                 19.1.7               ha7bfdaf_1    conda-forge
liblzma                   5.6.4                hb9d3cd8_0    conda-forge
libnetcdf                 4.9.2           nompi_h5ddbaa4_116    conda-forge
libnghttp2                1.64.0               h161d5f1_0    conda-forge
libnsl                    2.0.1                hd590300_0    conda-forge
libntlm                   1.8                  hb9d3cd8_0    conda-forge
libogg                    1.3.5                h4ab18f5_0    conda-forge
libopenblas               0.3.29          pthreads_h94d23a6_0    conda-forge
libopus                   1.3.1                h7f98852_1    conda-forge
libpciaccess              0.18                 hd590300_0    conda-forge
libpng                    1.6.47               h943b412_0    conda-forge
libpq                     17.4                 h27ae623_0    conda-forge
libsndfile                1.2.2                hc60ed4a_1    conda-forge
libsqlite                 3.49.1               hee588c1_1    conda-forge
libssh2                   1.11.1               hf672d98_0    conda-forge
libstdcxx                 14.2.0               hc0a3c3a_1    conda-forge
libstdcxx-ng              14.2.0               h4852527_1    conda-forge
libsystemd0               257.3                h3dc2cb9_0    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
libxcb                    1.17.0               h8a09558_0    conda-forge
libxcrypt                 4.4.36               hd590300_1    conda-forge
libxkbcommon              1.8.0                hc4a0caf_0    conda-forge
libxml2                   2.13.6               h8d12d68_0    conda-forge
libzip                    1.11.2               h6991a6a_0    conda-forge
libzlib                   1.3.1                hb9d3cd8_2    conda-forge
lz4-c                     1.10.0               h5888daf_1    conda-forge
mpg123                    1.32.9               hc50e24c_0    conda-forge
mysql-common              9.0.1                h266115a_4    conda-forge
mysql-libs                9.0.1                he0572af_4    conda-forge
ncurses                   6.4                  h6a678d5_0  
nspr                      4.36                 h5888daf_0    conda-forge
nss                       3.108                h159eef7_0    conda-forge
numpy                     2.0.2            py39h9cb892a_1    conda-forge
openldap                  2.6.9                he970967_0    conda-forge
openssl                   3.4.1                h7b32b05_0    conda-forge
packaging                 24.2               pyhd8ed1ab_2    conda-forge
pcre2                     10.44                hba22ea6_2    conda-forge
pip                       25.0             py39h06a4308_0  
pixman                    0.44.2               h29eaf8c_0    conda-forge
ply                       3.11               pyhd8ed1ab_3    conda-forge
pmw                       2.0.1           py39hf3d152e_1008    conda-forge
pthread-stubs             0.4               hb9d3cd8_1002    conda-forge
pulseaudio-client         17.0                 hb77b528_0    conda-forge
pymol-open-source         3.1.0            py39he07333a_0    conda-forge
pyqt                      5.15.9           py39h52134e7_5    conda-forge
pyqt5-sip                 12.12.2          py39h3d6467e_5    conda-forge
python                    3.9.18          h0755675_1_cpython    conda-forge
python_abi                3.9                      5_cp39    conda-forge
qt-main                   5.15.15              hc3cb62f_2    conda-forge
readline                  8.2                  h5eee18b_0  
setuptools                75.8.0           py39h06a4308_0  
sip                       6.7.12           py39h3d6467e_0    conda-forge
snappy                    1.2.1                h8bd8927_1    conda-forge
sqlite                    3.32.3               hcee41ef_1    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
toml                      0.10.2             pyhd8ed1ab_1    conda-forge
tomli                     2.2.1              pyhd8ed1ab_1    conda-forge
tzdata                    2025a                h04d1e81_0  
wheel                     0.45.1           py39h06a4308_0  
xcb-util                  0.4.1                hb711507_2    conda-forge
xcb-util-image            0.4.0                hb711507_2    conda-forge
xcb-util-keysyms          0.4.1                hb711507_0    conda-forge
xcb-util-renderutil       0.3.10               hb711507_0    conda-forge
xcb-util-wm               0.4.2                hb711507_0    conda-forge
xkeyboard-config          2.43                 hb9d3cd8_0    conda-forge
xorg-libice               1.1.2                hb9d3cd8_0    conda-forge
xorg-libsm                1.2.5                he73a12e_0    conda-forge
xorg-libx11               1.8.11               h4f16b4b_0    conda-forge
xorg-libxau               1.0.12               hb9d3cd8_0    conda-forge
xorg-libxdamage           1.1.6                hb9d3cd8_0    conda-forge
xorg-libxdmcp             1.1.5                hb9d3cd8_0    conda-forge
xorg-libxext              1.3.6                hb9d3cd8_0    conda-forge
xorg-libxfixes            6.0.1                hb9d3cd8_0    conda-forge
xorg-libxrender           0.9.12               hb9d3cd8_0    conda-forge
xorg-libxxf86vm           1.1.6                hb9d3cd8_0    conda-forge
xz                        5.6.4                h5eee18b_1  
zlib                      1.3.1                hb9d3cd8_2    conda-forge
zstd                      1.5.7                hb8e6e7a_0    conda-forge
@shaoqx
Copy link
Author

shaoqx commented Feb 22, 2025

I found if I set the start method of multiprocessing to "spawn" install of the default "fork" the problem is gone. However, fork is in principle more efficient and likely there is a bug related to pymol2.PyMol()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant