                     downloadData = response.data
                     downloadImage = response.image
                     resultError = response.error
-                    semaphore.signal()
+                    self.semaphore?.signal()
                 }
             )
-            semaphore.wait()
+            self.semaphore?.wait()
+            self.semaphore = nil
             self.query = nil
-            if workItem.isCancelled == false, let data = downloadData, let originImage = downloadImage {
+            if let data = downloadData, let originImage = downloadImage {
                 do {
                     try self.cache.set(data: data, image: originImage, url: self.url)
                     if workItem.isCancelled == false, let filter = self.filter, let image = filter.apply(originImage) {

    }
    
    private func _remoteWorkItem() -> DispatchWorkItem {
        let semaphore = DispatchSemaphore(value: 0)
        return DispatchWorkItem(block: { [weak self] in
            guard let self = self, let workItem = self.workItem else { return }
            var downloadData: Data?
            var downloadImage: UIImage?
            var resultImage: UIImage?
            var resultError: Error?
            self._progress(progress: Progress(totalUnitCount: 0))
            self.query = self.provider.send(
                request: QImageRequest(url: self.url),

    }
    
    public func cancel() {
        if let semaphore = self.semaphore {
            semaphore.signal()
            self.semaphore = nil
        }
        if let workItem = self.workItem {
            workItem.cancel()
            self.workItem = nil
