Skip to content

fix: initialize _lock attribute in ZipStore (#3588)#3761

Closed
abishop1990 wants to merge 1 commit intozarr-developers:mainfrom
abishop1990:fix/zipstore-lock-3588
Closed

fix: initialize _lock attribute in ZipStore (#3588)#3761
abishop1990 wants to merge 1 commit intozarr-developers:mainfrom
abishop1990:fix/zipstore-lock-3588

Conversation

@abishop1990
Copy link
Copy Markdown
Contributor

Summary

Fixes #3588.

ZipStore._lock was initialized in _sync_open() but accessed by methods (get, set, exists, etc.) that can be called before the store is explicitly opened. This caused:

AttributeError: 'ZipStore' object has no attribute '_lock'

Changes

  • Move self._lock = threading.RLock() from _sync_open() to __init__()
  • Add regression test test_lock_initialized_before_open

Testing

  • New test verifies _lock exists immediately after instantiation
  • All existing ZipStore tests pass
tests/test_store/test_zip.py  1 passed

ZipStore._lock was initialized in _sync_open() but accessed by methods
(get, set, exists, etc.) that can be called before the store is opened.
This caused AttributeError: 'ZipStore' object has no attribute '_lock'.

Move _lock initialization to __init__ so it is always available after
instantiation, regardless of whether the store has been opened yet.

Fixes zarr-developers#3588
@d-v-b
Copy link
Copy Markdown
Contributor

d-v-b commented Mar 11, 2026

thanks @abishop1990, how does this compare to #3593?

@abishop1990
Copy link
Copy Markdown
Contributor Author

I see PR #3593 is already addressing this issue. Closing to avoid duplicate work and let the existing PR move forward.

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.

AttributeError: 'ZipStore' object has no attribute '_lock'

2 participants