@@ -54,9 +54,7 @@ def _get_executor() -> ThreadPoolExecutor:
54
54
global _executor
55
55
if not _executor :
56
56
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 )
60
58
_executor = ThreadPoolExecutor (max_workers = max_workers , thread_name_prefix = "zarr_pool" )
61
59
_get_loop ().set_default_executor (_executor )
62
60
return _executor
@@ -118,6 +116,9 @@ def sync(
118
116
# NB: if the loop is not running *yet*, it is OK to submit work
119
117
# and we will wait for it
120
118
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 ()
121
122
if not isinstance (loop , asyncio .AbstractEventLoop ):
122
123
raise TypeError (f"loop cannot be of type { type (loop )} " )
123
124
if loop .is_closed ():
@@ -153,6 +154,7 @@ def _get_loop() -> asyncio.AbstractEventLoop:
153
154
# repeat the check just in case the loop got filled between the
154
155
# previous two calls from another thread
155
156
if loop [0 ] is None :
157
+ logger .debug ("Creating Zarr event loop" )
156
158
new_loop = asyncio .new_event_loop ()
157
159
loop [0 ] = new_loop
158
160
iothread [0 ] = threading .Thread (target = new_loop .run_forever , name = "zarr_io" )
0 commit comments