#2433 closed defect (fixed)
dead code: NamedTemporaryDirectory
Reported by: | zooko | Owned by: | daira |
---|---|---|---|
Priority: | minor | Milestone: | 1.10.1 |
Component: | code | Version: | 1.10.0 |
Keywords: | cleanup dead-code | Cc: | |
Launchpad Bug: |
Description (last modified by daira)
Looking at #2432, I noticed that NamedTemporaryDirectory is unused except for its unit test.
Now, the newer version of NamedTemporaryDirectory over in pyutil has an added feature — automatically call .close() on children when shutting down — which might be useful on Windows, but probably isn't. In any case, let's remove this older and unused version of NamedTemporaryDirectory from Tahoe-LAFS.
Change History (7)
comment:1 Changed at 2015-05-26T17:21:48Z by zooko
comment:2 Changed at 2015-05-26T18:22:29Z by Zooko <zookog@…>
- Resolution set to fixed
- Status changed from new to closed
comment:3 Changed at 2015-05-27T00:00:06Z by daira
- Milestone changed from undecided to 1.10.1
comment:4 Changed at 2015-05-27T00:00:39Z by daira
- Component changed from unknown to code
- Keywords cleanup dead-code added
- Priority changed from normal to minor
comment:5 Changed at 2015-05-27T00:05:11Z by daira
- Description modified (diff)
comment:6 Changed at 2015-05-27T00:05:28Z by daira
- Description modified (diff)
comment:7 Changed at 2015-05-27T00:18:12Z by daira
I looked at the implementation of NamedTemporaryFile in pyutil, and I think it may not work correctly for asynchronous tests. The problem is that the NamedTemporaryFile object may go out of scope and have its __del__ method called before all of the callback/errback chains associated with the test have finished (it's possible that the closures of those callbacks/errbacks might hold on to the object for long enough, but that seems error-prone and complicated to reason about).
If we were going to add automatic cleanup, I would want it to only be triggered in the test's cleanup phase. Even that is potentially a problem for diagnosing what happened by looking at the files under _trial_temp in case of a test failure.
https://github.com/tahoe-lafs/tahoe-lafs/pull/169