Re: [sage-devel] how to log sage output for long running program

2019-03-18 Thread Daniel Krenn
On 16.03.19 05:46, Ai Bo wrote:
> I am running a long running program. I would like to log the output.
> I have tried: 
>  ../sage-8.6/sage test.sage > test.log &

I used something along

  PYTHONUNBUFFERED=whatever ../sage-8.6/sage test.sage > test.log &

a couple of times.

Daniel

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] how to log sage output for long running program

2019-03-17 Thread 'Justin C. Walker' via sage-devel


> On Mar 16, 2019, at 02:33 , dimp...@gmail.com wrote:
> 
> On Fri, Mar 15, 2019 at 10:21:48PM -0700, 'Justin C. Walker' via sage-devel 
> wrote:
>> 
>>> On Mar 15, 2019, at 21:46 , Ai Bo  wrote:
>>> 
>>> I am running a long running program. I would like to log the output.
>>> I have tried: 
>>> ../sage-8.6/sage test.sage > test.log &
>>> 
>>> There is nothing written in test.log before the program finishes. 
>>> I tried to use tee, same problem.
>>> 
>>> I tried to add:
>>> f = open('test.log', 'w')
>>> 
>>> in my test.sage program, still nothing is written before the program 
>>> finishes.
>>> 
>>> How to log a long running program?
>> 
>> The problem, I think, is that python uses buffered output.  I assume that 
>> you are using print statements, so (without knowing more), I would use
>>  sys.stdout.flush()
>> after each print, or after points in your program where the state is useful 
>> for debugging.
>> 
>> If I’ve made the wrong assumptions, let us know.
> 
> I think he logs to f, so one would have to call f.flush() to flush the buffer.

Yep!  Thanks for catching that.

--
Justin C. Walker
Director
Institute for the Enhancement of the Director's Income
--
Fame is fleeting, but obscurity
   just drags on and on.  F&E



-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] how to log sage output for long running program

2019-03-16 Thread dimpase
On Fri, Mar 15, 2019 at 10:21:48PM -0700, 'Justin C. Walker' via sage-devel 
wrote:
> 
> > On Mar 15, 2019, at 21:46 , Ai Bo  wrote:
> > 
> > I am running a long running program. I would like to log the output.
> > I have tried: 
> >  ../sage-8.6/sage test.sage > test.log &
> > 
> > There is nothing written in test.log before the program finishes. 
> > I tried to use tee, same problem.
> > 
> > I tried to add:
> > f = open('test.log', 'w')
> > 
> > in my test.sage program, still nothing is written before the program 
> > finishes.
> > 
> > How to log a long running program?
> 
> The problem, I think, is that python uses buffered output.  I assume that you 
> are using print statements, so (without knowing more), I would use
>   sys.stdout.flush()
> after each print, or after points in your program where the state is useful 
> for debugging.
> 
> If I’ve made the wrong assumptions, let us know.

I think he logs to f, so one would have to call f.flush() to flush the buffer.

Dima

> 
> HTH
> 
> Justin
> 
> --
> Justin C. Walker
> Curmudgeon at Large
> Director
> Institute for the Enhancement of the Director's Income
> --
> Build a man a fire and he'll be warm
>  for a night.
> Set a man on fire and he'll be warm
>  for the rest of his life.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] how to log sage output for long running program

2019-03-15 Thread 'Justin C. Walker' via sage-devel


> On Mar 15, 2019, at 21:46 , Ai Bo  wrote:
> 
> I am running a long running program. I would like to log the output.
> I have tried: 
>  ../sage-8.6/sage test.sage > test.log &
> 
> There is nothing written in test.log before the program finishes. 
> I tried to use tee, same problem.
> 
> I tried to add:
> f = open('test.log', 'w')
> 
> in my test.sage program, still nothing is written before the program finishes.
> 
> How to log a long running program?

The problem, I think, is that python uses buffered output.  I assume that you 
are using print statements, so (without knowing more), I would use
  sys.stdout.flush()
after each print, or after points in your program where the state is useful for 
debugging.

If I’ve made the wrong assumptions, let us know.

HTH

Justin

--
Justin C. Walker
Curmudgeon at Large
Director
Institute for the Enhancement of the Director's Income
--
Build a man a fire and he'll be warm
 for a night.
Set a man on fire and he'll be warm
 for the rest of his life.



-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] how to log sage output for long running program

2019-03-15 Thread Ai Bo
I am running a long running program. I would like to log the output.
I have tried: 
 ../sage-8.6/sage test.sage > test.log &

There is nothing written in test.log before the program finishes. 
I tried to use tee, same problem.

I tried to add:
f = open('test.log', 'w')

in my test.sage program, still nothing is written before the program 
finishes.

How to log a long running program?

Thanks,

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.