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

bam reader won't close files and cause 'too many open files' error. #365

Open
y9c opened this issue Sep 12, 2022 · 0 comments
Open

bam reader won't close files and cause 'too many open files' error. #365

y9c opened this issue Sep 12, 2022 · 0 comments

Comments

@y9c
Copy link

y9c commented Sep 12, 2022

I tried to use rust-htslib to parse multiple regions in parallel. The bam files are read within a function call and the function is mapped into a .par_iter() chain. I expect the bam files are closed automatically after each loop. However, htslib keep opening new files and cause a too many open files error.

The code are within this repo:

https://github.com/y9c/mpileup/blob/12d8a589676c1d773425de0987666c29b4430394/src/base.rs#L426-L441

And the bug and be trigger by the following example.

cargo run base -t ./test/large_region.bed -r ./test/reference.fa -i test/sample1.bam test/sample2.bam > /dev/null

I am not sure if I am using htslib in a wrong way. Could you help me with this? Thank you.

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