Skip to content

Conversation

@dmitriyrepin
Copy link
Contributor

@dmitriyrepin dmitriyrepin commented Oct 6, 2025

This is an ugly fix for the bug 613 Open handles not properly cleaned up

BACKGROUD:

Invoking any Zarr cloud-accessing code in the same process as any code directly using fsspec (e.g., SegyFile) results in the
RuntimeError "Task attached to a different loop" (see Zarr issue #3487).

MDIO uses Xarray (which uses Zarr under the hood) to create or read MDIO cloud datasets from the main process.
To avoid the RuntimeError "Task attached to a different loop", no code using fsspec is permitted in the MDIO main process. Since SegyFile directly access fsspec, the SegyFile can't be instantiated in the main process.

WORKAROUND

This PR uses a ProcessPoolExecutor(max_workers=1) to read all information that MDIO needs from the SegyFile in a separate process using info_worker (the info_worker and its dependencies are currently placed in src/mdio/segy/_workers.py, but can be moved to other location)

@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 79.24528% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.84%. Comparing base (c3ba558) to head (027790e).
⚠️ Report is 186 commits behind head on main.

Files with missing lines Patch % Lines
src/mdio/segy/_workers.py 58.33% 10 Missing ⚠️
src/mdio/converters/segy.py 95.45% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #701      +/-   ##
==========================================
+ Coverage   85.30%   88.84%   +3.53%     
==========================================
  Files          46       84      +38     
  Lines        2219     4519    +2300     
  Branches      306      296      -10     
==========================================
+ Hits         1893     4015    +2122     
- Misses        281      435     +154     
- Partials       45       69      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tasansal tasansal force-pushed the bug-613_handles_not_cleaned_take_3 branch from 9d9fb29 to 8cae547 Compare October 8, 2025 21:25
@tasansal tasansal changed the title Fix bug 613 on top of latest main Refactor initial file information handling while avoiding asyncio issues. Oct 8, 2025
@tasansal tasansal added the enhancement New feature or request label Oct 8, 2025
@tasansal tasansal merged commit bbabc08 into TGSAI:main Oct 8, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants