File tree Expand file tree Collapse file tree
tests/FSharpx.Async.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ open System.Reflection
44[<assembly: AssemblyTitleAttribute( " FSharpx.Async" ) >]
55[<assembly: AssemblyProductAttribute( " FSharpx.Async" ) >]
66[<assembly: AssemblyDescriptionAttribute( " Async extensions for F#" ) >]
7- [<assembly: AssemblyVersionAttribute( " 1.11.0 " ) >]
8- [<assembly: AssemblyFileVersionAttribute( " 1.11.0 " ) >]
7+ [<assembly: AssemblyVersionAttribute( " 1.11.1 " ) >]
8+ [<assembly: AssemblyFileVersionAttribute( " 1.11.1 " ) >]
99do ()
1010
1111module internal AssemblyVersionInformation =
12- let [<Literal>] Version = " 1.11.0 "
12+ let [<Literal>] Version = " 1.11.1 "
Original file line number Diff line number Diff line change @@ -390,14 +390,17 @@ module AsyncSeq =
390390 let toBlockingSeq ( input : AsyncSeq < 'T >) =
391391 // Write all elements to a blocking buffer and then add None to denote end
392392 let buf = new BlockingQueueAgent<_>( 1 )
393- async {
394- do ! iterAsync ( Some >> buf.AsyncAdd) input
395- do ! buf.AsyncAdd( None) } |> Async.Start
393+ let iterator =
394+ async {
395+ let! res = iterAsync ( Some >> buf.AsyncAdd) input |> Async.Catch
396+ do ! buf.AsyncAdd( None)
397+ return match res with Choice2Of2 e -> raise e | _ -> ()
398+ } |> Async.StartAsTask
396399
397400 // Read elements from the blocking buffer & return a sequences
398401 let rec loop () = seq {
399402 match buf.Get() with
400- | None -> ()
403+ | None -> iterator.Result
401404 | Some v ->
402405 yield v
403406 yield ! loop() }
@@ -674,4 +677,4 @@ module Seq =
674677 /// Converts asynchronous sequence to a synchronous blocking sequence.
675678 /// The elements of the asynchronous sequence are consumed lazily.
676679 let ofAsyncSeq ( input : AsyncSeq < 'T >) =
677- AsyncSeq.toBlockingSeq input
680+ AsyncSeq.toBlockingSeq input
Original file line number Diff line number Diff line change 22
33open NUnit.Framework
44open FSharpx.Control
5+ open System
56
67/// Determines equality of two async sequences by convering them to lists, ignoring side-effects.
78let EQ ( a : AsyncSeq < 'a >) ( b : AsyncSeq < 'a >) =
@@ -236,4 +237,12 @@ let ``AsyncSeq.traverseChoiceAsync``() =
236237 | Choice2Of2 e ->
237238 Assert.AreEqual( " oh no" , e)
238239 Assert.True(([ 1 ; 2 ] = ( seen |> List.ofSeq)))
239-
240+
241+
242+ [<Test>]
243+ let ``AsyncSeq.toBlockingSeq does not hung forever and rethrows exception`` () =
244+ let s = asyncSeq {
245+ yield 1
246+ failwith " error"
247+ }
248+ Assert.Throws< AggregateException>( fun _ -> s |> AsyncSeq.toBlockingSeq |> Seq.toList |> ignore) |> ignore
You can’t perform that action at this time.
0 commit comments