11from __future__ import annotations
22
3+ import asyncio
34import io
45import os
56import shutil
89
910from zarr .abc .store import ByteRangeRequest , Store
1011from zarr .core .buffer import Buffer
11- from zarr .core .common import concurrent_map , to_thread
12+ from zarr .core .common import concurrent_map
1213
1314if TYPE_CHECKING :
1415 from collections .abc import AsyncGenerator , Iterable
@@ -134,7 +135,7 @@ async def get(
134135 path = self .root / key
135136
136137 try :
137- return await to_thread (_get , path , prototype , byte_range )
138+ return await asyncio . to_thread (_get , path , prototype , byte_range )
138139 except (FileNotFoundError , IsADirectoryError , NotADirectoryError ):
139140 return None
140141
@@ -159,7 +160,7 @@ async def get_partial_values(
159160 assert isinstance (key , str )
160161 path = self .root / key
161162 args .append ((_get , path , prototype , byte_range ))
162- return await concurrent_map (args , to_thread , limit = None ) # TODO: fix limit
163+ return await concurrent_map (args , asyncio . to_thread , limit = None ) # TODO: fix limit
163164
164165 async def set (self , key : str , value : Buffer ) -> None :
165166 return await self ._set (key , value )
@@ -178,7 +179,7 @@ async def _set(self, key: str, value: Buffer, exclusive: bool = False) -> None:
178179 if not isinstance (value , Buffer ):
179180 raise TypeError ("LocalStore.set(): `value` must a Buffer instance" )
180181 path = self .root / key
181- await to_thread (_put , path , value , start = None , exclusive = exclusive )
182+ await asyncio . to_thread (_put , path , value , start = None , exclusive = exclusive )
182183
183184 async def set_partial_values (
184185 self , key_start_values : Iterable [tuple [str , int , bytes | bytearray | memoryview ]]
@@ -189,19 +190,19 @@ async def set_partial_values(
189190 assert isinstance (key , str )
190191 path = self .root / key
191192 args .append ((_put , path , value , start ))
192- await concurrent_map (args , to_thread , limit = None ) # TODO: fix limit
193+ await concurrent_map (args , asyncio . to_thread , limit = None ) # TODO: fix limit
193194
194195 async def delete (self , key : str ) -> None :
195196 self ._check_writable ()
196197 path = self .root / key
197198 if path .is_dir (): # TODO: support deleting directories? shutil.rmtree?
198199 shutil .rmtree (path )
199200 else :
200- await to_thread (path .unlink , True ) # Q: we may want to raise if path is missing
201+ await asyncio . to_thread (path .unlink , True ) # Q: we may want to raise if path is missing
201202
202203 async def exists (self , key : str ) -> bool :
203204 path = self .root / key
204- return await to_thread (path .is_file )
205+ return await asyncio . to_thread (path .is_file )
205206
206207 async def list (self ) -> AsyncGenerator [str , None ]:
207208 """Retrieve all keys in the store.
0 commit comments