Skip to content

Commit 5f876d2

Browse files
committed
fix RemoteStore._exists
1 parent 1d46753 commit 5f876d2

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/zarr/store/remote.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from zarr.buffer import BufferPrototype
1010
from zarr.common import AccessModeLiteral
1111
from zarr.store.core import _dereference_path
12+
from zarr.sync import RuntimeSyncError
1213

1314
if TYPE_CHECKING:
1415
from fsspec.asyn import AsyncFileSystem
@@ -88,6 +89,8 @@ def _exists(self) -> bool:
8889
return bool(self._fs.exists(self.path))
8990
except self.allowed_exceptions:
9091
return False
92+
except RuntimeSyncError:
93+
return False
9194

9295
def __str__(self) -> str:
9396
return f"{self._url}"

src/zarr/sync.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class SyncError(Exception):
3131
pass
3232

3333

34+
class RuntimeSyncError(RuntimeError):
35+
pass
36+
37+
3438
def _get_lock() -> threading.Lock:
3539
"""Allocate or return a threading lock.
3640
@@ -72,7 +76,7 @@ def sync(
7276
if not isinstance(loop, asyncio.AbstractEventLoop):
7377
raise TypeError(f"loop cannot be of type {type(loop)}")
7478
if loop.is_closed():
75-
raise RuntimeError("Loop is not running")
79+
raise RuntimeSyncError("Loop is not running")
7680
try:
7781
loop0 = asyncio.events.get_running_loop()
7882
if loop0 is loop:

tests/v3/test_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from zarr.sync import SyncError, SyncMixin, _get_lock, _get_loop, sync
7+
from zarr.sync import RuntimeSyncError, SyncError, SyncMixin, _get_lock, _get_loop, sync
88

99

1010
@pytest.fixture(params=[True, False])
@@ -67,7 +67,7 @@ def test_sync_raises_if_loop_is_closed() -> None:
6767

6868
foo = AsyncMock(return_value="foo")
6969
with patch.object(loop, "is_closed", return_value=True):
70-
with pytest.raises(RuntimeError):
70+
with pytest.raises(RuntimeSyncError):
7171
sync(foo(), loop=loop)
7272
foo.assert_not_awaited()
7373

0 commit comments

Comments
 (0)