Details
-
Type:
Bug
-
Status: To Do
-
Resolution: Unresolved
-
Fix Version/s: None
-
Component/s: log
-
Labels:None
-
Team:Data Access and Database
Description
Running the attached test file exposes a problem with using FileAppender.
$ python small.py
|
.File open: /home/srp/mine/legacy-ctrl_events/tests/test.log
|
F.
|
======================================================================
|
FAIL: testFileDescriptorLeaks (__main__.smallMemoryTestCase)
|
----------------------------------------------------------------------
|
Traceback (most recent call last):
|
File "/scratch/srp/lsstsw/stack/Linux64/utils/13.0/python/lsst/utils/tests.py", line 178, in testFileDescriptorLeaks
|
self.fail("Failed to close %d file%s" % (len(diff), "s" if len(diff) != 1 else ""))
|
AssertionError: Failed to close 1 file
|
As a side note, since the file isn't flushed at any point, the test.log file ends up being empty. edit: this is because it was being sent to trace, not info.
The tests in lsst.log don't use the lsst.utils.tests framework so this bug wasn't exposed. Additionally, the test that is there in testLog.py names the file "
{0}" - I'm not sure what this was supposed to be
Attachments
Issue Links
- mentioned in
-
Page Loading...
Note that files will always be closed on program exit: the operating system takes care of that for you. The issue here is that the log system opens a file during test execution, and that file isn't closed again when that particular test is finished. The test suite interprets as a leak. I've updated the title of this ticket to reflect that.
I suspect that this is actually a problem with the test in question: I don't think a well formed unit test should modify its environment. I therefore agree that leaving files open on test exit which weren't open when the test started is a failure. That means: if you open a log file during a test, you'd better close it too, or your test is wrong.
However, I'm not sure how easy it is to meet that goal. Maybe Hsin-Fang Chiang could comment?