RE: [Zope] Re: Unfair Linux Threads And Python Oh My
-----Original Message----- From: Chris McDonough [mailto:chrism@digicool.com] Sent: 26 April 2000 06:08 To: Evan Simpson Cc: Tony Rossignol; Tres Seaver; Marcus Collins; Bill Anderson; zope@zope.org Subject: Re: [Zope] Re: Unfair Linux Threads And Python Oh My
Can a few folks with BSD/Solaris/HPUX/whateverotherthanLinux boxes try the script that Tony found and see what it does on their machines?
$ uname -mrs FreeBSD 3.3-STABLE i386 The test script forks a single child and starts chowing cpu, but produces no output on the terminal (it keeps looping in the while 1: pass). Some observations: If I replace the call to sys.stderr.write with a simple print, then I get a single asterisk. Is sys.stderr.write() perhaps buffered? If, instead of forking a child, I just let the thread take care of printing (as in, e.g., http://www.python.org/doc/FAQ.html#4.86), then all works as expected. hth, -- Marcus
Marcus Collins wrote:
If I replace the call to sys.stderr.write with a simple print, then I get a single asterisk. Is sys.stderr.write() perhaps buffered?
I thought it was, but I just tried:
sys.stderr.write('*'); time.sleep(3); sys.stderr.write('*\n') **
and had the first asterisk printed immediately (on python shipped with RedHat 6.1). I don't think you can rely on it being unbuffered, but being a file object it does have a flush() method. Regards, Daryl Tester
Marcus Collins wrote:
-----Original Message----- From: Chris McDonough [mailto:chrism@digicool.com] Sent: 26 April 2000 06:08 To: Evan Simpson Cc: Tony Rossignol; Tres Seaver; Marcus Collins; Bill Anderson; zope@zope.org Subject: Re: [Zope] Re: Unfair Linux Threads And Python Oh My
Can a few folks with BSD/Solaris/HPUX/whateverotherthanLinux boxes try the script that Tony found and see what it does on their machines?
$ uname -mrs FreeBSD 3.3-STABLE i386
The test script forks a single child and starts chowing cpu, but produces no output on the terminal (it keeps looping in the while 1: pass).
Some observations:
If I replace the call to sys.stderr.write with a simple print, then I get a single asterisk. Is sys.stderr.write() perhaps buffered?
Call it with "python -u" and it is unbuffered: """-u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)""" Likewise, dropping off the fork() and rearranging the code removed the problem. -- In flying I have learned that carelessness and overconfidence are usually far more dangerous than deliberately accepted risks. -- Wilbur Wright in a letter to his father, September 1900
participants (3)
-
Bill Anderson -
Daryl Tester -
Marcus Collins