Welcome! Please see the About page for a little more info on how this works.

+6 votes
in core.async by

After running into a race-condition involving closed timeout channels, it seems like it would be appropriate to mention that close! should never be called on a timeout channel in its docstring. The attached patch tweaks the doc string to that effect. Please advise if you'd like the wording changed a bit.

4 Answers

+2 votes

Comment made by: alexmiller

Yeah, I think it would be better to fix this than doc it.

+1 vote
Reference: https://clojure.atlassian.net/browse/ASYNC-109 (reported by alex+import)
> Yeah, I think it would be better to fix this than doc it.

I for one would very much welcome the patch for turning this into an error. Would have saved us around 3 days of intense debugging of very strange timeout behavior in a busy server.
As an alternative it might be considered to revert https://github.com/clojure/core.async/commit/ca80990bdcef6c46a93b93b82a3337fff22432d7
Another strong reason to revert it is that you can easily run into the 1024 taker limit unexpectedly. Check the following repro, assuming your machine is fast enough:
(let [err (promise)
      chs (into [] (repeatedly 32 #(a/timeout 1000)))]
  (doseq [ch chs]
    (dotimes [_ 33]
      (try (a/take! ch (fn [_]))
           (catch Error e
             (deliver err e)))))

This may also be a sleeper in existing core.async deployments that will only surface once machines become faster.
0 votes

Comment made by: hlewisship

Alternately/additionally, it would be nice if close! on a timeout channel would throw an exception.

0 votes

Comment made by: slipset

or alternately, make it a no-op?