@@ -54,9 +54,7 @@ def _get_executor() -> ThreadPoolExecutor:
5454 global _executor
5555 if not _executor :
5656 max_workers = config .get ("threading.max_workers" , None )
57- print (max_workers )
58- # if max_workers is not None and max_workers > 0:
59- # raise ValueError(max_workers)
57+ logger .debug ("Creating Zarr ThreadPoolExecutor with max_workers=%s" , max_workers )
6058 _executor = ThreadPoolExecutor (max_workers = max_workers , thread_name_prefix = "zarr_pool" )
6159 _get_loop ().set_default_executor (_executor )
6260 return _executor
@@ -118,6 +116,9 @@ def sync(
118116 # NB: if the loop is not running *yet*, it is OK to submit work
119117 # and we will wait for it
120118 loop = _get_loop ()
119+ if _executor is None and config .get ("threading.max_workers" , None ) is not None :
120+ # trigger executor creation and attach to loop
121+ _ = _get_executor ()
121122 if not isinstance (loop , asyncio .AbstractEventLoop ):
122123 raise TypeError (f"loop cannot be of type { type (loop )} " )
123124 if loop .is_closed ():
@@ -153,6 +154,7 @@ def _get_loop() -> asyncio.AbstractEventLoop:
153154 # repeat the check just in case the loop got filled between the
154155 # previous two calls from another thread
155156 if loop [0 ] is None :
157+ logger .debug ("Creating Zarr event loop" )
156158 new_loop = asyncio .new_event_loop ()
157159 loop [0 ] = new_loop
158160 iothread [0 ] = threading .Thread (target = new_loop .run_forever , name = "zarr_io" )
0 commit comments