Currently, clojure.core/print-sequential has the potential for
problems in the face of thread interruption. When you print a large
sequence, and interrupt the thread doing the printing, the only way
I'm aware of to get it to stop printing is to call the evil
Thread.stop [1]. In REPLy, I'm currently monkey-patching some
Thread.interrupted checks into print-sequential so that I can avoid
Thread.stop when printing sequences.
Would there be interest in a patch for print-sequential that would
cause an InterruptedException to be thrown when Thread.interrupt is
called on a thread?
This would replace the current behavior of continuing to print until
the end of the sequence, with the interrupted flag set on the thread.
There's an argument to be made that the calling code should be
responsible for checking the flag. But since print-sequential is
really a loop with [potentially] lots of writes internally, my
thinking is that the loop should do its own Thread.interrupted
monitoring.
Thoughts?
- Colin
[1]
http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Thread.html#stop()
--
Colin Jones
@trptcolin