| 1 |
__test__ = False |
| 2 |
|
| 3 |
if __name__ == '__main__': |
| 4 |
import eventlet |
| 5 |
eventlet.monkey_patch() |
| 6 |
import subprocess |
| 7 |
import gc |
| 8 |
|
| 9 |
p = subprocess.Popen(['ls'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 10 |
# the following line creates a _SocketDuckForFd(3) and .close()s it, but the |
| 11 |
# object has not been collected by the GC yet |
| 12 |
p.communicate() |
| 13 |
|
| 14 |
f = open('/dev/null', 'rb') # f.fileno() == 3 |
| 15 |
gc.collect() # this calls the __del__ of _SocketDuckForFd(3), close()ing it again |
| 16 |
|
| 17 |
f.close() # OSError, because the fd 3 has already been closed |
| 18 |
print('pass') |