Skip to content

fix generator completion in randomstats - #435

Merged
daler merged 5 commits into
daler:v0.12.2rcfrom
rpinho:fix-randomstats
Nov 28, 2026
Merged

daler merged 5 commits into
daler:v0.12.2rcfrom
rpinho:fix-randomstats

Conversation

@rpinho

@rpinho rpinho commented Nov 18, 2026 •

Copy link
Copy Markdown

Python 3.7 changed how StopIteration is handled inside a generator, converting it into RuntimeError. This was the cause of issues like #377, when running BedTool.randomstats() to get an empirical distribution of overlaps of randomly shuffled intervals.

This PR also includes a test to ensure that pools are cleaned up correctly, which was not happening before.

Original PR description from @rpinho below.

As reported in #377, randomstats raises RuntimeError when its generators finish. Run randomstats with two processes on the bundled a.bed and b.bed files to reproduce the error. Let the generators return after yielding their results, close streams through close(), and release the pools created by the generators. The regression test compares the returned counts with BEDTools for both randomstats modes.

Fixes #377.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N

@daler
daler changed the base branch from master to v0.12.2rc November 27, 2026 20:31
@daler
daler merged commit 81b0e41 into daler:v0.12.2rc Nov 28, 2026
7 checks passed
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

Successfully merging this pull request may close these issues.

'generator raised StopIteration' error when running 'randomstats' with multiple processes

2 participants