Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Decorators and buffer flushing

Reply
Thread Tools

Decorators and buffer flushing

 
 
Ethan Metsger
Guest
Posts: n/a
 
      02-28-2008
Hi, all.

I apologize for what is perhaps a newb question. I'm in the process of
transitioning our testing framework from Perl to Python. While that alone
probably sets off some red flags, I'm afraid it's what I'm stuck with.

I'm modeling a test with five operations: build, execute, validate,
publish, and clean. The main loop might look something like this:

with Test(...) as t:
t.build()
t.execute()
t.validate()
t.publish()

At each run, I want to output a '.' to denote completion of that test
step. I've been able to do this, sort of, using the following decorator
(edited for brevity):

def report(f):

def new(self):
stat = f(self);

if stat is True:
sys.stdout.write ('.')

else:
...

sys.stdout.flush()

return new

(Each one of the test functions returns True or False depending on its
completion status.)

The problem is that rather than outputting a period after each step is
completed, it outputs all four of them at once. Instead of seeing
progress as it happens, I get it when it's finished, even though I'm
flushing the output buffer.

Any thoughts?


Best,

Ethan ()
http://uppertank.net/ethanm/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Decorators and buffer flushing Ethan Metsger Python 5 03-03-2008 05:06 PM
Accelerated C++ - Chapter 1, confusion in understanding "flushing the buffer" arnuld C++ 5 03-18-2007 11:14 AM
Flushing servers buffer Andyza ASP General 3 07-07-2005 06:50 PM
stdin - flushing buffer - this should be an easy one tj Perl Misc 2 05-04-2004 08:55 PM
Flushing the Buffer in .Net Eric ASP .Net 3 04-25-2004 11:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57