New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore Failure on Mono: System.Exception: Expected an result at this place. #2639
Comments
@0x53A Yeah I have no idea how it is possible to reach this code-place, that's the reason why I added the bool variable after all. If the bool is true the result should be set after the task finishes (which it is after the task is finished). Yeah let's look at this closely and leave this open for a while. |
Hm, I don't think simple variables are guaranteed to be consistent across Threads. Edit: this sets |
Tbh I'd expect the variable to be read from the same thread, but whatever |
Thread 1 sets |
Ah fuck, thanks :) |
Was only thinking about the bool variable. Ok then we could make the result part of the task and map the task later. The bad thing about this is than this unused value is in the cache :/. |
I don't really understand the code, and why do you have the Choice? As I understand it, the first call gets Choice1, subsequent calls get Choice2? That's not really memoize anymore ;-) The simplest code, imo, would be: let internal memoizeAsyncEx (f: 'iext -> 'i -> Async<'o * 'oext>) =
let cache = System.Collections.Concurrent.ConcurrentDictionary<'i, System.Threading.Tasks.Task<'o>>()
let handle (ex:'iext) (x:'i) : Choice<System.Threading.Tasks.Task<'o>, Async<'o * 'oext>> =
let task = cache.GetOrAdd(x, fun x ->
let tcs = TaskCompletionSource()
Async.Start (async {
try
let! o, oext = f ex x
tcs.SetResult o
with
exn ->
tcs.SetException exn
})
tcs.Task)
Choice1Of2 task
handle That puts a Task from a TCS into the dictionary. The async call runs in the background in the threadpool and sets the TCS when it finishes / fails. But this would lose the distinction between first call / later calls |
@0x53A Yes this is a bit strange and I have no idea how to better encode it.
|
Ah, ok, so you do a request, and key it by the source. So it gets blacklisted if the first request fails, but stays non-blacklisted, if the first succeeds, but the second one fails, right? Please, please, create a custom DU for that stuff and don't abuse the poor Choice ;) |
Like I said I'm open for suggestions. I'm not sure if DU is the problem in this particular snippet :). But yeah a good idea! |
Yeah basically, however it seems like this is not always working as expected. I saw urls being blacklisted later and paket continuing it's job. Maybe I have failed somewhere. |
I've been skimming through the travis logs and found one error that looked ... interesting:
https://travis-ci.org/fsprojects/Paket/jobs/266475236#L1953
It comes from this line:
Paket/src/Paket.Core/Common/Utils.fs
Lines 62 to 82 in ca538da
Just judging from the context, it seems like this should not happen and represents either a mono async issue, or an actual bug. But I haven't analyzed it in any way.
If you don't care about this, just close the issue ;-)
The text was updated successfully, but these errors were encountered: