aurora-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sweeney" <kevi...@apache.org>
Subject Review Request 33455: Use "a" mode instead of "w" when opening stdout and stderr.
Date Wed, 22 Apr 2015 22:47:58 GMT

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/33455/
-----------------------------------------------------------

Review request for Aurora and Brian Wickman.


Repository: aurora


Description
-------

Use "a" mode instead of "w" when opening stdout and stderr.

This allows an external log rotation process to truncate stdout and stderr without causing
the creation of a sparse file.


Diffs
-----

  src/main/python/apache/thermos/core/process.py 5ce138dab161d880c0bd58b87a6f5a54d4ca2f99


Diff: https://reviews.apache.org/r/33455/diff/


Testing
-------

With "w" mode testfile is 300 bytes despite being truncated externally.
```
% python 3> testfile
Python 2.7.6 (default, Sep  9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> f = os.fdopen(3, 'w')
>>> f.write(100 * 'a')
>>> f.flush()

% echo -n '' > testfile

>>> f.write(200 * 'b')
>>> f.flush()
% ls -l testfile
-rw-r--r--  1 ksweeney  staff  300 Apr 22 15:40 testfile
```

With "a" mode testfile is 200 bytes.
```
% python 3> testfile
Python 2.7.6 (default, Sep  9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> f = os.fdopen(3, 'a')
>>> f.write(100 * 'a')
>>> f.flush()

% echo -n '' > testfile

>>> f.write(200 * 'b')
>>> f.flush()

% ls -l testfile
-rw-r--r--  1 ksweeney  staff  200 Apr 22 15:40 testfile
```


Thanks,

Kevin Sweeney


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message