Closed anton-pt closed 9 years ago
I just got an InvalidOperationException
with the message Async.FromContinuations was invoked multiple time
" when using the AwaitObservable
that takes only a single IObservable
in FSharpx.Async
1.12.0
Is this commit already in the nuget package of in FSharpx.Async 1.12.0
?
I am calling AwaitObservable
from within an Async
returned by AwaitObservable
that is still running. Might this be causing the problem? Are your tests covering that case?
Sorry, there was some issue with one of my unit tests which was causing the build server to hang or something so the PR wasn't accepted. I keep meaning to sort it out but forgetting. I'll try to do it ASAP.
Your commit does actually fix my problem. Thank you so much for that!
@exercitusvir I have just submitted a PR to the FSharpx.Async project which contains the updated code: https://github.com/fsprojects/FSharpx.Async/pull/30 as I don't think this project is maintained anymore.
With the previous implementation of AwaitObservable, hot observables (returned from methods such as Observable.Replay) would result in multiple continuation functions being called as the observer OnNext, OnError and OnCompleted methods are sometimes called as soon as the subscription is made. Added some failing unit tests to show this behaviour and changed the implementation of AwaitObservable to pass them. The new implementation starts a finite state machine style agent internally.
The unit tests in AwaitObservableTests.fs were set to be ignored as they were previously failing erratically. The new implementation seems to fix that (they each passed 1000 repeats here) so I have re-enabled them.