Amber-MD/pytraj

autoimage too many open files

shalkya opened this issue · 4 comments

I have a script that goes over a lot of dynamics, make autoimage, and write a pdb files for each frames. This script crash every ~500 dynamics (=25000 frames), due to a Too many open files error with autoimage. The script launched without autoimage, doesn't crash.

for pdb, path_pdb in Dpdb.items():
  traj = pt.load(f'{path_pdb}/{pdb}.nc', f'{path_pdb}/{pdb}.ions.solv.top')
  traj = pt.autoimage(traj, mask=f'@CA')

Only this part of the script lead to a crash (without autoimage it works fine)

Traceback (most recent call last):
  File "post_prod.py", line 221, in <module>
    traj = pt.autoimage(traj, mask=f'@CA')
  File "/home/user/anaconda3/envs/env/lib/python3.6/site-packages/pytraj/utils/get_common_objects.py", line 314, in inner
    return f(*args, **kwargs)
  File "/home/user/anaconda3/envs/env/lib/python3.6/site-packages/pytraj/all_actions.py", line 1160, in autoimage
    do_action(traj, command, c_action.Action_AutoImage, top=top)
  File "/home/user/anaconda3/envs/env/lib/python3.6/site-packages/pytraj/analysis/c_action/__init__.py", line 26, in do_action
    with capture_stdout() as (out, _):
  File "/home/user/anaconda3/envs/env/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/home/user/anaconda3/envs/env/lib/python3.6/site-packages/pytraj/externals/wurlitzer.py", line 252, in pipes
    with w:
  File "/home/user/anaconda3/envs/env/lib/python3.6/site-packages/pytraj/externals/wurlitzer.py", line 156, in __enter__
    pipe = self._setup_pipe('stderr')
  File "/home/user/anaconda3/envs/env/lib/python3.6/site-packages/pytraj/externals/wurlitzer.py", line 106, in _setup_pipe
    pipe_out, pipe_in = os.pipe()
OSError: [Errno 24] Too many open files

Is there a way to deal with this issue ?

hainm commented

I think this was fixed in latest release. Which version are you using?

I am using pytraj 2.0.5

hainm commented

Please try this

#1498 (comment)

This work around does work, thank you.