core.async

Writing on a closed channel doesn't commit the handler

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test

Description

(let [closed (doto (a/chan) a/close!)
      open (a/chan)]
  (a/go-loop []
    (a/alts! [open [closed true]] :priority true)
    (recur)))

throws

Exception in thread "async-dispatch-1" java.lang.AssertionError: Assert failed: No more than 1024 pending takes are allowed on a single channel.
(< (.size takes) impl/MAX-QUEUE-SIZE)
	at clojure.core.async.impl.channels.ManyToManyChannel.take_BANG_(channels.clj:235)
	at clojure.core.async$do_alts$fn__8030.invoke(async.clj:253)
	at clojure.core.async$do_alts.invokeStatic(async.clj:245)
	at clojure.core.async$do_alts.invoke(async.clj:237)

my analysis is that when a write is attempted on a closed channel the handler should be commited, so as to allow cleanup of the handler registrations on other channels.

See https://github.com/clojure/core.async/blob/822920a45e5ea7fa28641922559fdeb888c15d05/src/main/clojure/clojure/core/async/impl/channels.clj#L74-L75

Activity

Hide
Christophe Grand added a comment -

Attached patch

Show
Christophe Grand added a comment - Attached patch

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: