| 1 | Index: twisted/internet/test/test_process.py |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- twisted/internet/test/test_process.py (revision 31396) |
|---|
| 4 | +++ twisted/internet/test/test_process.py (working copy) |
|---|
| 5 | @@ -599,6 +599,15 @@ |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | +class FakeFile(object): |
|---|
| 10 | + """ |
|---|
| 11 | + A fake file object which pretends it can be closed. |
|---|
| 12 | + """ |
|---|
| 13 | + def close(self): |
|---|
| 14 | + pass |
|---|
| 15 | + |
|---|
| 16 | + |
|---|
| 17 | + |
|---|
| 18 | class FakeResourceModule(object): |
|---|
| 19 | """ |
|---|
| 20 | Fake version of L{resource} which hard-codes a particular rlimit for maximum |
|---|
| 21 | @@ -682,8 +691,14 @@ |
|---|
| 22 | """ |
|---|
| 23 | This is a mock for L{open}. It just keeps track of the fact that a file |
|---|
| 24 | has opened so an extra file descriptor is found in /dev/fd. |
|---|
| 25 | + |
|---|
| 26 | + It also returns a L{FakeFile} which can be "closed". It would be more |
|---|
| 27 | + realistic to make the FD list shrink when the file is "fake closed" but |
|---|
| 28 | + it's not necessary for the detection algorithm we currently have in |
|---|
| 29 | + process.py. |
|---|
| 30 | """ |
|---|
| 31 | self.openedFile = True |
|---|
| 32 | + return FakeFile() |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | def saveResourceModule(self): |
|---|
| 36 | Index: twisted/internet/process.py |
|---|
| 37 | =================================================================== |
|---|
| 38 | --- twisted/internet/process.py (revision 31396) |
|---|
| 39 | +++ twisted/internet/process.py (working copy) |
|---|
| 40 | @@ -530,6 +530,7 @@ |
|---|
| 41 | start = self.listdir("/dev/fd") |
|---|
| 42 | fp = self.openfile("/dev/null", "r") |
|---|
| 43 | end = self.listdir("/dev/fd") |
|---|
| 44 | + fp.close() |
|---|
| 45 | return start != end |
|---|
| 46 | |
|---|
| 47 | |
|---|