title: Swift 3, URLSession dataTask completionHandler not called
body: <p>I am writing a library, So not using UIKit, Even in my iOS app same code works, but when i execute in command line in doesn't . In PlayGround also it seems working.</p>
  
  <p>For some reason callback is not getting triggered, so print statements are not executing.</p>
  
  <pre><code>internal class func post(request: URLRequest, responseCallback: @escaping (Bool, AnyObject?) -&gt; ()) {
      execTask(request: request, taskCallback: { (status, resp)  -&gt; Void in
              responseCallback(status, resp)
      })
  }
  
  internal class func clientURLRequest(url: URL, path: String, method: RequestMethod.RawValue,  params: Dictionary&lt;String, Any&gt;? = nil) -&gt; URLRequest {
      var request = URLRequest(url: url)
      request.httpMethod = method
      do {
          let jsonData = try JSONSerialization.data(withJSONObject: (params! as [String : Any]), options: .prettyPrinted)
  
          request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
          request.httpBody = jsonData
      } catch let error as NSError {
          print(error)
      }
      return request
  }
  
  private class func execTask(request: URLRequest, taskCallback: @escaping (Bool,
      AnyObject?) -&gt; ()) {
  
      let session = URLSession(configuration: URLSessionConfiguration.default)
      print("THIS LINE IS PRINTED")
      let task = session.dataTask(with: request, completionHandler: {(data, response, error) -&gt; Void in
          if let data = data {
              print("THIS ONE IS NOT PRINTED")
              let json = try? JSONSerialization.jsonObject(with: data, options: [])
              if let response = response as? HTTPURLResponse , 200...299 ~= response.statusCode {
                  taskCallback(true, json as AnyObject?)
              } else {
                  taskCallback(false, json as AnyObject?)
              }
          }
      })
      task.resume()
  }
  </code></pre>
  
  <p>Edits -: I am writing a library, So not using UIKit, Even in my iOS app same code works, but when i execute in command line in doesn't . In PlayGround also it seems working.</p>