Re:Using core.async and transducers to upload files from the...
by danneu on Thursday September 04, 2014 @01:03PM
(#8269382)
> I still need to look into some things like
> how to properly shut down the `go` blocks.
I have limited core.async experience, but one simple solution would be to replace `(go (while true ... (<! report-chan)))` with a `core.async/go-loop` that `alts!` from `[report-chan, (core.async/timeout 10000)]`. If the value comes from `report-chan`, then recur. If the value comes from the timeout channel (10 seconds of no activity) then don't thus ending the go block execution.
For more control, you can pass a poison channel in from the outside. In the go-loop, `alts!` from `[report-chan, poison-chan, (timeout 10000)]`. Like the timeout channel, don't recur if the value comes from poison-chan. And that's a chan that your exterior code will have access to.
Re:Using core.async and transducers to upload files from the...
by freshhawk on Thursday September 04, 2014 @06:24PM
(#8271006)
I'm pretty sure that the alts! block is absolutely necessary otherwise you will deadlock after 10 files (your channel buffer size) because nothing else is taking from upload-chan or signing-chan.
Wouldn't a pipeline be a better solution to this? Taking and throwing away the values from a channel just to trigger a transducer that puts the value in another channel as a side effect is a strange way to do things.
Also a simple println test will show that the transducer function is triggered when you put on the channel rather than when you take.
For more control, you can pass a poison channel in from the outside. In the go-loop, `alts!` from `[report-chan, poison-chan, (timeout 10000)]`. Like the timeout channel, don't recur if the value comes from poison-chan. And that's a chan that your exterior code will have access to.
Wouldn't a pipeline be a better solution to this? Taking and throwing away the values from a channel just to trigger a transducer that puts the value in another channel as a side effect is a strange way to do things.
Also a simple println test will show that the transducer function is triggered when you put on the channel rather than when you take.