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