def GetExtensionVersion(self, vi): isapi.simple.SimpleExtension.GetExtensionVersion(self, vi) # As per Q192800, the CompletionPort should be created with the number # of processors, even if the number of worker threads is much larger. # Passing 0 means the system picks the number. self.io_req_port = CreateIoCompletionPort(-1, None, 0, 0) # start up the workers self.workers = [] for i in range(self.max_workers): worker = WorkerThread(self, self.io_req_port) worker.start() self.workers.append(worker)
def addWatch(self, path, mask=0): """Add watcher for path""" super(WinFileSysMonitor, self).addWatch(path, mask) handle = CreateFileW( path, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE, None, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, None) buf = AllocateReadBuffer(self.buf_size) if not mask: mask = self.defaultMask self.__lock.acquire() self.ioComPort = CreateIoCompletionPort(handle, self.ioComPort, self.comKey, 0) self.watchList.append({'mask': mask, 'path': path, 'handle': handle, 'buffer': buf}) self.comKey += 1 self.__lock.release()