Skip to content
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

BufferByCountAndTime impact to Async.StartWithContinuations #65

Closed
vaspas opened this issue Apr 20, 2017 · 5 comments · Fixed by #73
Closed

BufferByCountAndTime impact to Async.StartWithContinuations #65

vaspas opened this issue Apr 20, 2017 · 5 comments · Fixed by #73

Comments

@vaspas
Copy link

vaspas commented Apr 20, 2017

Description

Async.StartWithContinuations call is blocked when using AsyncSeq.BufferByCountAndTime in async operation.

Repro steps

let op =
asyncSeq{
while true do
do! Async.Sleep 1000
yield 0
}
|> AsyncSeq.bufferByCountAndTime 10 1000
|> AsyncSeq.iter (printf "%A ")

let cts = new System.Threading.CancellationTokenSource()
Async.StartWithContinuations(op, ignore, ignore, ignore, cts.Token)

Expected behavior

Async.StartWithContinuations call is returned

Actual behavior

Async.StartWithContinuations call blocks thread.

Known workarounds

Related information

  • Windows 10
  • FSharp.Control.AsyncSeq (2.0.11)
@eulerfx
Copy link
Contributor

eulerfx commented Apr 20, 2017 via email

@eulerfx
Copy link
Contributor

eulerfx commented Sep 26, 2017

Hey, following up on this. It looks like the issue is the printf inside iter. This causes blocking even without bufferByTimeAndCount. If you instead call printfn then it works. If printfn is expanded it looks like this:

Printf.kfprintf (fun _ -> Console.Out.WriteLine()) Console.Out "%A" x

and printf is the same except the call to Console.Out.WriteLine(). So somehow, that calls unblocks the thread. If you instead call iterAsync and prepend with a call to do! Async.SwitchToThreadPool () then the thread is unblocked, however the still no printing.

Odd.

@vaspas
Copy link
Author

vaspas commented Sep 27, 2017

Hello.

I have added waiting in example above.
Async.StartWithContinuations is returned then AsyncSeq.bufferByCountAndTime is excluded from pipeline.

@eulerfx
Copy link
Contributor

eulerfx commented Sep 27, 2017

To clarify my comment, things work as expected if you use printfn rather than printf..

@vaspas
Copy link
Author

vaspas commented Sep 27, 2017

Only iterAsync with do! Async.SwitchToThreadPool () works for me.
printfn has the same blocking effect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants