* [Caml-list] lwt exceptions and infinite loops
@ 2013-11-19 4:48 Ivan Gotovchits
2013-11-19 9:21 ` Jeremie Dimino
2013-11-19 11:06 ` Jacques-Pascal Deplaix
0 siblings, 2 replies; 6+ messages in thread
From: Ivan Gotovchits @ 2013-11-19 4:48 UTC (permalink / raw)
To: caml-list
consider the following simple example:
open Lwt
let rec loop () = Lwt_unix.sleep 1. >> loop ()
let bad () = Lwt_unix.sleep 1. >> fail Not_found
let () = Lwt_main.run (join [loop (); bad ()])
This program never terminates with an exception as I expect.
Can someone clarify to me what really happens underneath the hood?
Thanks in advance!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] lwt exceptions and infinite loops
2013-11-19 4:48 [Caml-list] lwt exceptions and infinite loops Ivan Gotovchits
@ 2013-11-19 9:21 ` Jeremie Dimino
2013-11-19 12:32 ` Ivan Gotovchits
2013-11-19 11:06 ` Jacques-Pascal Deplaix
1 sibling, 1 reply; 6+ messages in thread
From: Jeremie Dimino @ 2013-11-19 9:21 UTC (permalink / raw)
To: Ivan Gotovchits; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 583 bytes --]
On Tue, Nov 19, 2013 at 4:48 AM, Ivan Gotovchits <ivg@ieee.org> wrote:
> consider the following simple example:
>
> open Lwt
> let rec loop () = Lwt_unix.sleep 1. >> loop ()
> let bad () = Lwt_unix.sleep 1. >> fail Not_found
> let () = Lwt_main.run (join [loop (); bad ()])
>
>
> This program never terminates with an exception as I expect.
>
> Can someone clarify to me what really happens underneath the hood?
>
Lwt.join waits for all thread to terminate (with a value or an exception).
In this case [loop ()] is still running so the join doesn't terminate.
--
Jeremie
[-- Attachment #2: Type: text/html, Size: 1033 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] lwt exceptions and infinite loops
2013-11-19 4:48 [Caml-list] lwt exceptions and infinite loops Ivan Gotovchits
2013-11-19 9:21 ` Jeremie Dimino
@ 2013-11-19 11:06 ` Jacques-Pascal Deplaix
2013-11-19 11:11 ` Raphaël Proust
1 sibling, 1 reply; 6+ messages in thread
From: Jacques-Pascal Deplaix @ 2013-11-19 11:06 UTC (permalink / raw)
To: caml-list
Where did you find the operator (>>) ? Your function loop doesn't
terminate because (>>) evaluates both arguments.
On 11/19/2013 05:48 AM, Ivan Gotovchits wrote:
> consider the following simple example:
>
> open Lwt
> let rec loop () = Lwt_unix.sleep 1. >> loop ()
> let bad () = Lwt_unix.sleep 1. >> fail Not_found
> let () = Lwt_main.run (join [loop (); bad ()])
>
>
> This program never terminates with an exception as I expect.
>
> Can someone clarify to me what really happens underneath the hood?
>
> Thanks in advance!
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] lwt exceptions and infinite loops
2013-11-19 11:06 ` Jacques-Pascal Deplaix
@ 2013-11-19 11:11 ` Raphaël Proust
2013-11-19 11:35 ` Jacques-Pascal Deplaix
0 siblings, 1 reply; 6+ messages in thread
From: Raphaël Proust @ 2013-11-19 11:11 UTC (permalink / raw)
To: Jacques-Pascal Deplaix; +Cc: OCaml Mailing List
On Tue, Nov 19, 2013 at 11:06 AM, Jacques-Pascal Deplaix
<jp.deplaix@gmail.com> wrote:
> Where did you find the operator (>>) ? Your function loop doesn't
> terminate because (>>) evaluates both arguments.
Lwt's syntax extensions provides (>>) as sugar for `>>= fun () ->`.
http://ocsigen.org/lwt/api/Pa_lwt
>
> On 11/19/2013 05:48 AM, Ivan Gotovchits wrote:
>> consider the following simple example:
>>
>> open Lwt
>> let rec loop () = Lwt_unix.sleep 1. >> loop ()
>> let bad () = Lwt_unix.sleep 1. >> fail Not_found
>> let () = Lwt_main.run (join [loop (); bad ()])
>>
>>
>> This program never terminates with an exception as I expect.
>>
>> Can someone clarify to me what really happens underneath the hood?
>>
>> Thanks in advance!
>>
--
______________
Raphaël Proust
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] lwt exceptions and infinite loops
2013-11-19 11:11 ` Raphaël Proust
@ 2013-11-19 11:35 ` Jacques-Pascal Deplaix
0 siblings, 0 replies; 6+ messages in thread
From: Jacques-Pascal Deplaix @ 2013-11-19 11:35 UTC (permalink / raw)
To: Raphaël Proust; +Cc: OCaml Mailing List
Oh ok, I didn't know that, thanks.
On 11/19/2013 12:11 PM, Raphaël Proust wrote:
> On Tue, Nov 19, 2013 at 11:06 AM, Jacques-Pascal Deplaix
> <jp.deplaix@gmail.com> wrote:
>> Where did you find the operator (>>) ? Your function loop doesn't
>> terminate because (>>) evaluates both arguments.
> Lwt's syntax extensions provides (>>) as sugar for `>>= fun () ->`.
>
> http://ocsigen.org/lwt/api/Pa_lwt
>
>
>> On 11/19/2013 05:48 AM, Ivan Gotovchits wrote:
>>> consider the following simple example:
>>>
>>> open Lwt
>>> let rec loop () = Lwt_unix.sleep 1. >> loop ()
>>> let bad () = Lwt_unix.sleep 1. >> fail Not_found
>>> let () = Lwt_main.run (join [loop (); bad ()])
>>>
>>>
>>> This program never terminates with an exception as I expect.
>>>
>>> Can someone clarify to me what really happens underneath the hood?
>>>
>>> Thanks in advance!
>>>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] lwt exceptions and infinite loops
2013-11-19 9:21 ` Jeremie Dimino
@ 2013-11-19 12:32 ` Ivan Gotovchits
0 siblings, 0 replies; 6+ messages in thread
From: Ivan Gotovchits @ 2013-11-19 12:32 UTC (permalink / raw)
To: Jeremie Dimino; +Cc: caml-list
Jeremie Dimino <jdimino@janestreet.com> writes:
> On Tue, Nov 19, 2013 at 4:48 AM, Ivan Gotovchits <ivg@ieee.org> wrote:
>
> consider the following simple example:
>
> open Lwt
> let rec loop () = Lwt_unix.sleep 1. >> loop ()
> let bad () = Lwt_unix.sleep 1. >> fail Not_found
> let () = Lwt_main.run (join [loop (); bad ()])
>
> This program never terminates with an exception as I expect.
>
> Can someone clarify to me what really happens underneath the hood?
>
> Lwt.join waits for all thread to terminate (with a value or an exception). In this case [loop ()] is still running so the join doesn't
> terminate.
>
> --
> Jeremie
>
Ahh, it seems that I misunderstood the phrase:
«If one of the threads fails, then [join l] will fail with the same
exception as the first one to terminate.»
Thanks alot!
--
(__)
(oo)
/------\/
/ | ||
* /\---/\
~~ ~~
...."Have you mooed today?"...
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-11-19 12:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-19 4:48 [Caml-list] lwt exceptions and infinite loops Ivan Gotovchits
2013-11-19 9:21 ` Jeremie Dimino
2013-11-19 12:32 ` Ivan Gotovchits
2013-11-19 11:06 ` Jacques-Pascal Deplaix
2013-11-19 11:11 ` Raphaël Proust
2013-11-19 11:35 ` Jacques-Pascal Deplaix
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox