Skip to content

Conversation

@grahamfindlay
Copy link

The json.load(open(...)) pattern leaves file handles open, causing ResourceWarning when Python is run with warnings enabled. This is particularly noisy when using multiprocessing, as each worker triggers the warning when importing the module.

Changes:

  • neuropixels_tools.py: Use context manager in _load_np_probe_features()
  • testing.py: Use context manager when loading JSON schema

Both files now properly close file handles using 'with' statements.

The json.load(open(...)) pattern leaves file handles open, causing
ResourceWarning when Python is run with warnings enabled. This is
particularly noisy when using multiprocessing, as each worker triggers
the warning when importing the module.

Changes:
- neuropixels_tools.py: Use context manager in _load_np_probe_features()
- testing.py: Use context manager when loading JSON schema

Both files now properly close file handles using 'with' statements.

Fixes issue reported for Python 3.14 on Linux with forkserver multiprocessing.
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.

1 participant