Make print-sequential interruptible


  • Type: Feature Feature
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4, Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Approval:


This allows print-sequential to be interrupted by Thread.interrupt(), rather than requiring clients to resort to Thread.stop(). This is especially helpful when printing very large sequences.

See also clojure-dev discussion at

Patch: clj-1073-add-print-interruptibly-patch-v2.txt


Add a new var print-interruptibly, similar to print-length, print-dup, etc. Its default is false. When true, (Thread/interrupted) is checked for after printing each element of a sequence. If true, the writer is flushed and an InterruptedIOException is thrown.

An alternative patch proposed earlier did not include print-interruptibly, but simply always checked (Thread/interrupted) after printing each element of a sequence. Benchmark tests showed that this could slow down printing of long sequences by about 10%. The approach in the proposed patch only incurs this slowdown if print-interruptibly is true. When false, there is no significant slowdown measured in benchmarks.

  1. 0001-Allow-thread-interruption-in-print-sequential.patch
    21/Sep/12 4:10 PM
    1 kB
    Colin Jones
  2. clj-1073-add-print-interruptibly-patch-v2.txt
    13/Feb/13 12:28 AM
    4 kB
    Andy Fingerhut
  3. perftest-print.clj
    21/Sep/12 7:05 PM
    0.3 kB
    Andy Fingerhut
    21/Sep/12 7:05 PM
    0.3 kB
    Andy Fingerhut



Vote (1)
Watch (2)


  • Created: