     }
 
     override func main() {
+        let semaphore = DispatchSemaphore(value: 0)
 
         let completion: (Data?, URLResponse?, Error?) -> () = { [weak self] data, response, error in
+            defer {
+                semaphore.signal()
+            }
+            
             guard let `self` = self, !self.isCancelled else { return }
 
             if let error = error {

        case(#keyPath(URLSessionTask.countOfBytesReceived)):
            callbacks.onRecive(task.countOfBytesReceived, task.countOfBytesExpectedToReceive)
        default:
            break
        }
    }


            
            task?.resume()
        }
        
        semaphore.wait()
    }
    
    override func observeValue(
