From: Robert C. <cim...@nt...> - 2009-04-24 19:04:51
|
Ryan May wrote: > On Fri, Apr 24, 2009 at 5:52 AM, Esmail <eb...@ho...> wrote: > >> Ryan May wrote: >>> Any idea if it's possible to finish a Python program but still have >> the >>> graph showing? >>> >>> FWIW, I'm doing this under Linux. >>> >>> >>> You'd have to run the plotting in a separate process from the >>> computation. subprocess would let you do that, assuming you can spin >>> off a child task that stays alive when the parent exits. You'd also >>> need to get the computing process to give new results to the child plot, >>> maybe using a pipe (which I think subprocess can handle as well.) >> Thanks Ryan, I have been meaning to explore Python's >> threading/multi-processing facilities, so this will provide a >> good excuse to do so :-) [when I find the time... so much to learn, >> so little time] > > > I was curious, so I cooked up a quick demo using two scripts. Put them in > the same directory and run datasource.py. It's not perfect, and I think the > use of raw_input() is a little odd, but it works. Nice! I will try using the subprocess module instead of multiprocessing, as your example works for me. Thanks! r. |