caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Lwt_pool usage
@ 2010-11-25 16:48 Sergey Plaksin
  2010-11-25 17:02 ` [Caml-list] " Jérémie Dimino
  0 siblings, 1 reply; 2+ messages in thread
From: Sergey Plaksin @ 2010-11-25 16:48 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

lwt 2.1.1
========== Code:
open Lwt
let cococo = ref 0
let connections = Lwt_pool.create 1 (fun () -> let () =  (incr cococo) 
in return (string_of_int !cococo))
let test x dbh =
catch (fun _ ->
    Lwt_io.printl ("Start " ^ x ^ dbh) >>
    Lwt_unix.sleep 1.0 >>
    Lwt_io.printl ( "[" ^ x ^ "] A " ^ dbh) >>
    Lwt_unix.sleep 1.0 >>
    Lwt_io.printl ( "[" ^ x^ "] B " ^ dbh) >>
    Lwt_unix.sleep 1.0 >>
    Lwt_io.printl ( "[" ^ x^ "] C " ^ dbh );
)
(fun e -> Lwt_io.printl ( "[" ^ x ^ "] Cancelled " ^ dbh ^ " " ^  
Printexc.to_string e) >> Lwt.fail e)

let ct n = Lwt_pool.use connections (test n)
let t = Lwt.join [ct "t1"; ct "t2" ; ct "t3";  ct "t4"; ct "t5" ] in 
Lwt_main.run t

============ Compilation command:
ocamlfind ocamlc -o test -syntax camlp4o -package 
lwt,lwt.unix,lwt.syntax -linkpkg test.ml
====================== Output:
Start t51
[t5] A 1
[t5] B 1
[t5] C 1
Start t41
[t4] Cancelled 1 Lwt.Canceled
Start t31
[t3] Cancelled 1 Lwt.Canceled
Start t21
[t2] Cancelled 1 Lwt.Canceled
Start t11
[t1] Cancelled 1 Lwt.Canceled
Fatal error: exception Lwt.Canceled
========================

What's wrong in code? Why it raise Canceled exception?




[-- Attachment #2: Type: text/html, Size: 11448 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Lwt_pool usage
  2010-11-25 16:48 Lwt_pool usage Sergey Plaksin
@ 2010-11-25 17:02 ` Jérémie Dimino
  0 siblings, 0 replies; 2+ messages in thread
From: Jérémie Dimino @ 2010-11-25 17:02 UTC (permalink / raw)
  To: Sergey Plaksin; +Cc: caml-list

On Thu, Nov 25, 2010 at 07:48:49PM +0300, Sergey Plaksin wrote:
>    What's wrong in code? Why it raise Canceled exception?

It was a bug in Lwt 2.1.1, it has been fixed in the development version.

Cheers,
Jérémie


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-25 17:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-25 16:48 Lwt_pool usage Sergey Plaksin
2010-11-25 17:02 ` [Caml-list] " Jérémie Dimino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).