File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 11from  __future__ import  annotations 
22
3+ import  asyncio 
34from  dataclasses  import  dataclass 
45from  typing  import  TYPE_CHECKING 
56
@@ -32,14 +33,14 @@ async def _decode_single(
3233        cdata  =  chunk_bytes .as_array_like ()
3334        # decompress 
3435        if  self .compressor :
35-             chunk  =  self .compressor .decode ( cdata )
36+             chunk  =  await   asyncio . to_thread ( self .compressor .decode ,  cdata )
3637        else :
3738            chunk  =  cdata 
3839
3940        # apply filters 
4041        if  self .filters :
4142            for  f  in  reversed (self .filters ):
42-                 chunk  =  f .decode ( chunk )
43+                 chunk  =  await   asyncio . to_thread ( f .decode ,  chunk )
4344
4445        # view as numpy array with correct dtype 
4546        chunk  =  ensure_ndarray_like (chunk )
@@ -71,15 +72,15 @@ async def _encode_single(
7172        # apply filters 
7273        if  self .filters :
7374            for  f  in  self .filters :
74-                 chunk  =  f .encode ( chunk )
75+                 chunk  =  await   asyncio . to_thread ( f .encode ,  chunk )
7576
7677        # check object encoding 
7778        if  ensure_ndarray_like (chunk ).dtype  ==  object :
7879            raise  RuntimeError ("cannot write object array without object codec" )
7980
8081        # compress 
8182        if  self .compressor :
82-             cdata  =  self .compressor .encode ( chunk )
83+             cdata  =  await   asyncio . to_thread ( self .compressor .encode ,  chunk )
8384        else :
8485            cdata  =  chunk 
8586
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments