-
Notifications
You must be signed in to change notification settings - Fork 180
Closed
Milestone
Description
The following code demonstrates the bad behavior. For some reason, it looks like the connections are never closed. (Also, it's possible that I'm just doing something wrong with the resource handling here.). The original example is from Paolo Donadeo, but I made it a bit simpler.
open Core.Std
open Async.Std
open Log.Global
let make_request () =
let url = "http://google.com" in
Cohttp_async.Client.get (Uri.of_string url)
>>= fun (r, b) ->
Cohttp_async.Body.to_string b
>>| fun body_text ->
info "RESPONSE BODY: %s [SNIP]" (String.slice body_text 0 37);
let status = Cohttp.Response.status r in
match status with
| `OK -> ()
| _ -> error "Unexpected reply. HTTP status was: %s"
(Cohttp.Code.string_of_status status)
let main_loop () =
info "Program starts";
let rec loop n =
info "======================================= Making request #%03d" n;
make_request ()
>>= fun () ->
loop (n + 1)
in
loop 1
let () = main_loop () |> Deferred.don't_wait_for
let () = never_returns (Scheduler.go ())
Metadata
Metadata
Assignees
Labels
No labels