From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id C368FBBAF for ; Thu, 25 Nov 2010 17:48:42 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao0BAA8i7kzRVdc2kWdsb2JhbACCApMFjX8IFQEBAQEJCwoHEQMfpUyJZIIYhHwuiFYBAQMFhUIEhFeGCoMPZ4Ee X-IronPort-AV: E=Sophos;i="4.59,256,1288566000"; d="scan'208,217";a="80223717" Received: from mail-ew0-f54.google.com ([209.85.215.54]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Nov 2010 17:48:42 +0100 Received: by ewy24 with SMTP id 24so15800498ewy.27 for ; Thu, 25 Nov 2010 08:48:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type; bh=KIfAWu1m5HvxnUU0AeO+BLa18fy3KCig3gMEG1XFkYE=; b=J5OcA5l/t0fQR5X9rBOpIn87UXqFdTG98feAkstIxwoQMBGpoOjGpfumC3DIAC8r22 oQBJF0vnXw79/2cZXPAv1uDKzGDJPR+MPvEZW5R0p5OOAzaNFOFUnOHZ+uWw9l+6ggqh mAHtlBgky8nnIScG2MEQuBGXNPEvdl3Gk9A54= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=Bu+vbTW1tMcttLJv9a0RNsVkWKiqYFbukID9X9LlwREZoljoNMJ5lt5ajigrRDB4of ubG55Wq+RTkOfMF8hbCWK4trXr/Cg55ieHl9Fqm6JJ0JUIWGbEFbq1kzsN7Od61FpUq9 bHT1dGApLYR1Vh5QI/dTbIQFYgDJ+I4NpRqPQ= Received: by 10.213.33.133 with SMTP id h5mr2748270ebd.89.1290703721783; Thu, 25 Nov 2010 08:48:41 -0800 (PST) Received: from [192.168.21.49] (s1.inventos.ru [193.232.50.1]) by mx.google.com with ESMTPS id v51sm869338eeh.22.2010.11.25.08.48.40 (version=SSLv3 cipher=RC4-MD5); Thu, 25 Nov 2010 08:48:40 -0800 (PST) Message-ID: <4CEE9371.1080806@gmail.com> Date: Thu, 25 Nov 2010 19:48:49 +0300 From: Sergey Plaksin User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101028 Lanikai/3.1.6 MIME-Version: 1.0 To: caml-list@inria.fr Subject: Lwt_pool usage Content-Type: multipart/alternative; boundary="------------070508080204080407070707" X-Spam: no; 0.00; printexc:01 compilation:01 ocamlfind:01 ocamlc:01 camlp:01 -package:01 syntax:01 -linkpkg:01 printexc:01 compilation:01 ocamlfind:01 ocamlc:01 camlp:01 -package:01 syntax:01 This is a multi-part message in MIME format. --------------070508080204080407070707 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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? --------------070508080204080407070707 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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?



--------------070508080204080407070707-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id C24C0BBAF for ; Thu, 25 Nov 2010 18:02:49 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEABol7kzVuiYS/2dsb2JhbACjDnG/UA2FOgSPdQ X-IronPort-AV: E=Sophos;i="4.59,255,1288566000"; d="scan'208";a="89379239" Received: from solaria.dimino.org ([213.186.38.18]) by mail1-smtp-roc.national.inria.fr with ESMTP; 25 Nov 2010 18:02:49 +0100 Received: from aurora (localhost.localdomain [127.0.0.1]) by solaria.dimino.org (Postfix) with ESMTP id 1779C8004E; Thu, 25 Nov 2010 18:02:49 +0100 (CET) Received: by aurora (Postfix, from userid 1000) id 80C8040B61; Thu, 25 Nov 2010 18:02:53 +0100 (CET) Date: Thu, 25 Nov 2010 18:02:53 +0100 From: =?iso-8859-1?Q?J=E9r=E9mie?= Dimino To: Sergey Plaksin Cc: caml-list@inria.fr Subject: Re: [Caml-list] Lwt_pool usage Message-ID: <20101125170253.GB16604@aurora> References: <4CEE9371.1080806@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4CEE9371.1080806@gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam: no; 0.00; bug:01 cheers:01 sergey:98 wrote:01 exception:01 caml-list:01 raise:03 thu:05 wrong:10 version:13 what's:14 2010:83 code:17 nov:17 25,:82 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