Skip to content
Tcl Source Code View Ticket
Login

View Ticket

a non-blocking [chan pipe] channel blocks when internal buffers fill up

Closed / Invalidf8fe1ebdc6ff050e29c50ad632d8195d33cc4293Created 8 years agoUpdated 8 years ago
Descriptionwiki2019-04-29 06:52:29
The following script never completes because once Tcl's internal buffers fill up, writable events on the channel no longer occur.

variable total 0
proc write chan {
    variable total
    variable done
    set data [info cmdcount][string repeat abcdefghijklmnopqrstuvwxyz 100]
    set len [string length $data]
    puts [list writing $len characters]
    puts $chan $data
    if {[incr total $len] > 1048576} {
        close $chan
        set done 1
    }
}
lassign [chan pipe] pr pw 
chan configure $pw -blocking 0
chan event $pw writable [list write $pw]
vwait done
puts done
pooryorickwiki2019-04-29 07:56:04

The documentation for [chan write] states, "A channel is considered to be writable if at least one byte of data can be written to the underlying file or device without blocking, or if an error condition is present on the underlying file or device."

Therefore, this is the expected behaviour.

pooryorick Closed ticket [f8fe1ebdc6]. [History diff]2019-04-29 08:29:04
Log in (anonymous is fine) to add a comment.