Skip to content

Commit ab00a98

Browse files
committed
Workspace: Completely disable splitting loading in a separate thread
1 parent c7466e0 commit ab00a98

File tree

1 file changed

+2
-53
lines changed

1 file changed

+2
-53
lines changed

src/histalign/backend/workspace/__init__.py

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -316,59 +316,8 @@ def run(self):
316316
self.volume.loaded.emit()
317317
return
318318

319-
# Download
320-
process = Process(target=self.volume._ensure_downloaded)
321-
process.start()
322-
while process.is_alive():
323-
if self.isInterruptionRequested():
324-
process.kill()
325-
return
326-
327-
time.sleep(0.1)
328-
329-
self.volume.downloaded.emit()
330-
331-
# Load
332-
queue = Queue()
333-
process = Process(
334-
target=_load_volume, args=(self.volume.path, queue), daemon=True
335-
)
336-
337-
_module_logger.debug("Starting volume loader process.")
338-
byte_array = bytearray()
339-
process.start()
340-
while process.is_alive():
341-
if self.isInterruptionRequested():
342-
_module_logger.debug("VolumeLoaderThread interrupted.")
343-
process.kill()
344-
return
345-
346-
while not queue.empty():
347-
byte_array += queue.get()
348-
349-
if self.isInterruptionRequested():
350-
_module_logger.debug("VolumeLoaderThread interrupted.")
351-
process.kill()
352-
return
353-
354-
time.sleep(0.1)
355-
356-
# Reconstruct the NumPy array
357-
dtype = nrrd.reader._determine_datatype(nrrd.read_header(str(self.volume.path)))
358-
array = np.ndarray(
359-
# We can't get the shape directly from self.volume as that would force a call
360-
# to `ensure_loaded` and load the volume to get the answer.
361-
shape=VolumeSettings.get_shape_from_resolution(self.volume.resolution),
362-
dtype=dtype,
363-
buffer=byte_array,
364-
order="F",
365-
)
366-
367-
# Potentially normalise fast
368-
array = io.normalise_array(array, self.volume.dtype, fast=True)
369-
370-
self.volume.update_from_array(array)
371-
self.volume.loaded.emit()
319+
self.volume._ensure_downloaded()
320+
self.volume._ensure_loaded()
372321

373322
@staticmethod
374323
def _run(volume: Volume, queue: Queue) -> None:

0 commit comments

Comments
 (0)