QThread locks process on folder



  • i'm trying to convert qt's QFileInfoGatherer to python the code below is a stripped version of it. The issue im running into is that when QFileSystemWatcher is inside of the Thread it locks the folder if a folder is in its children.

    so lets say you have the folders:
    path/A
    path/A/B

    you cant delete A from an os level because a process is latched on you can however delete A AFTER B is deleted.

    How can i fix this? or what am I missing?

    from PySide.QtCore import *
    from PySide.QtGui import *
    
    class FileGatherer(QThread):
        def __init__(self, parent=None):
            super(FileGatherer, self).__init__(parent)
    
            self.muteX = QMutex()
            self.condition = QWaitCondition()
    
            self.abort = False
            self.paths = []
            self.watcher = QFileSystemWatcher(self)
    
            self.start(self.LowPriority)
        def run(self):
            while True:
                locker = QMutexLocker(self.muteX)
                if self.abort:
                    return
                if not len(self.paths):
                    print "waiting"
                    self.condition.wait(self.muteX)
                else:
                    print "running"
                locker.unlock()
    

Log in to reply