core.async

put! does not throw on closed channel

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    rev 1bf8cf4

Description

The docstring of put! says "Will throw if closed". However, put!-ing to a closed channel appears to succeed, and even calls the supplied callback.

I'm not sure which is incorrect - the behavior or the docstring (or my intepretation of it) - but it does appear that the implementation of mult is expecting an exception from put!, in order to do cleanup.

Activity

Hide
Justin Balthrop added a comment -

The doc string for put! no longer says "Will throw if closed" for clojure.core.async, though it does still say this for cljs.core.async (and doesn't seem to work).

It looks like Rich started switching put! to return true unless the channel is closed in cf8dc1bf207e646c14b2bf44763737fcb5f08c78. The docstring reflects this change, but from my testing, put! still always returns nil.

Show
Justin Balthrop added a comment - The doc string for put! no longer says "Will throw if closed" for clojure.core.async, though it does still say this for cljs.core.async (and doesn't seem to work). It looks like Rich started switching put! to return true unless the channel is closed in cf8dc1bf207e646c14b2bf44763737fcb5f08c78. The docstring reflects this change, but from my testing, put! still always returns nil.
Hide
Sung Pae added a comment -

Since this is likely a docstring mismatch, I'd like to add that the docstring for clojure.core.async/put states:

Asynchronously puts a val into port, calling fn1 (if supplied) when complete, passing true iff port is already closed.

fn1 is passed `false` when the port is closed, not `true`.

Show
Sung Pae added a comment - Since this is likely a docstring mismatch, I'd like to add that the docstring for clojure.core.async/put states:
Asynchronously puts a val into port, calling fn1 (if supplied) when complete, passing true iff port is already closed.
fn1 is passed `false` when the port is closed, not `true`.
Hide
Alex Miller added a comment -

Docstring addressed with ASYNC-89

Show
Alex Miller added a comment - Docstring addressed with ASYNC-89

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: