cluster()/_do_clustering(): pass files as tuple instead of list

- the sequence isn't modified anywhere between cluster() and _clustering_finished() (that loops over it)
This commit is contained in:
Laurent Monin
2024-05-24 12:15:24 +02:00
parent 17c7768a5e
commit 745767bcce

View File

@@ -1281,15 +1281,15 @@ class Tagger(QtWidgets.QApplication):
def cluster(self, objs, callback=None):
"""Group files with similar metadata to 'clusters'."""
log.debug("Clustering %r", objs)
files = iter_files_from_objects(objs)
files = tuple(iter_files_from_objects(objs))
thread.run_task(
partial(self._do_clustering, list(files)),
partial(self._do_clustering, files),
partial(self._clustering_finished, callback))
def _do_clustering(self, files):
# The clustering algorithm should completely run in the thread,
# hence do not return the iterator.
return list(Cluster.cluster(files))
return tuple(Cluster.cluster(files))
def _clustering_finished(self, callback, result=None, error=None):
if error: