Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Randall R Schulz
On Thursday 18 December 2008 14:44, Randall R Schulz wrote: > On Thursday 18 December 2008 14:40, Stephan Mühlstrasser wrote: > > ... > > > > As Chouser pointed out, the flush is the important ingredient. > > > > After thinking a while about this, I'm wondering why it is > > necessary. The output

Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Randall R Schulz
On Thursday 18 December 2008 14:40, Stephan Mühlstrasser wrote: > On Dec 18, 11:30 pm, Randall R Schulz wrote: > > On Thursday 18 December 2008 13:33, Stephan Mühlstrasser wrote: > > > > > > Nothing fancy: > > > > (defn cat-stream > > > >   (.flush *out*))) > > As Chouser pointed out, the fl

Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Stephan Mühlstrasser
On Dec 18, 11:30 pm, Randall R Schulz wrote: > On Thursday 18 December 2008 13:33, Stephan Mühlstrasser wrote: > > > Nothing fancy: > > (defn cat-stream > >   (.flush *out*))) > As Chouser pointed out, the flush is the important ingredient. After thinking a while about this, I'm wondering

Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Randall R Schulz
On Thursday 18 December 2008 13:33, Stephan Mühlstrasser wrote: > On Dec 18, 10:01 pm, Randall R Schulz wrote: > > > My question was not precise enough. I meant why can the parent > > > process - the Clojure program - terminate before all all the > > > output has been passed through. > > > > Beca

Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Dave Griffith
> > Ah, I believe I finally understand the difference between send and > send-off. To describe it in my own words, send-off creates a new > thread each time, while send schedules to a thread in a thread pool. > Not quite true, but close. Send-off requests a thread from a CachingThreadPool, but

Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Stephan Mühlstrasser
On Dec 18, 10:01 pm, Randall R Schulz wrote: > > > My question was not precise enough. I meant why can the parent > > process - the Clojure program - terminate before all all the output > > has been passed through. > > Because it can terminate whenever it wants to. Child processes do not > place

Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Stephan Mühlstrasser
On Dec 18, 10:10 pm, Chouser wrote: > On Thu, Dec 18, 2008 at 3:07 PM, Stephan Mühlstrasser > > wrote: > > > The following is my attempt to start a sub-process and to pass through > > stdout and stderr.  The shell command prints out 1000 lines "hello" > > and a final "command finished". The prob

Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Chouser
On Thu, Dec 18, 2008 at 3:07 PM, Stephan Mühlstrasser wrote: > > The following is my attempt to start a sub-process and to pass through > stdout and stderr. The shell command prints out 1000 lines "hello" > and a final "command finished". The problem is that nothing is printed > by the Clojure p

Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Randall R Schulz
On Thursday 18 December 2008 12:43, Stephan Mühlstrasser wrote: > On Dec 18, 9:24 pm, Randall R Schulz wrote: > > On Thursday 18 December 2008 12:07, Stephan Mühlstrasser wrote: > > > ... > > > > > > Is this use of agents incorrect? > > > > I would say it's an appropriate use, but you need to do

Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Stephan Mühlstrasser
On Dec 18, 9:24 pm, Randall R Schulz wrote: > On Thursday 18 December 2008 12:07, Stephan Mühlstrasser wrote: > > > (let [pb (new ProcessBuilder ["sh" "-c" "yes hello | head -1000; echo > > command finished"]) > >         proc (.start pb) > >         stdout (reader (.getInputStream proc)) > >  

Re: (Ab)using agents for inter-process communication

2008-12-18 Thread Randall R Schulz
On Thursday 18 December 2008 12:07, Stephan Mühlstrasser wrote: > Hi, > > I've not yet seen any examples on how to deal with external processes > in Clojure (I hope I didn't overlook something in clojure-contrib). > > The following is my attempt to start a sub-process and to pass > through stdout

(Ab)using agents for inter-process communication

2008-12-18 Thread Stephan Mühlstrasser
Hi, I've not yet seen any examples on how to deal with external processes in Clojure (I hope I didn't overlook something in clojure-contrib). The following is my attempt to start a sub-process and to pass through stdout and stderr. The shell command prints out 1000 lines "hello" and a final "co