Win Tests fail: dataLoadThread sometimes destroyed before thread.finished()
Not completely sure what's happening yet, but I'm making progress figuring out why the tests are failing on windows:
The failing test is just tests/test_datamodel/test_folder(). skip that test and the tests pass.
Looks like the problem is caused when DataModel.loadFromPath() calls setContainer(), which starts the DataLoadThread QThread. I'm not exactly sure where the error then happens, but if _dataSourceChanged is emitted or setPos(0) is called before the thread is done, you get the QThread deletion error on windows that fails the tests...
If I add a thread.finished.connect slot to the method, (as shown below), the tests/test_datamodel/ tests will pass... but then I get a
AttributeError: 'DataModel' object has no attribute 'pos' error on spimagine/gui/mainwidget.py line 575:
def setContainer(self, dataContainer=None, prefetchSize=0):
self.dataContainer = dataContainer
self.prefetchSize = prefetchSize
self.nset = [0]
self.data = defaultdict(lambda: None)
if self.dataContainer:
def onThreadDone():
self.setPos(0)
self._dataSourceChanged.emit()
self.stopDataLoadThread()
self.dataLoadThread.load(self.nset, self.data, self.dataContainer)
self.dataLoadThread.finished.connect(onThreadDone)
self.dataLoadThread.start(priority=QtCore.QThread.LowPriority)
so in short, I don't have a global solution, since I don't quite understand the data loading / prefetching well enough yet. But that's a start...
it's also perhaps worth pointing out that it would be enough for now to just comment out or add a @nottest decorator to the test_datamodel/test_folder() test to allow the tests to pass while this is figured out.