Bugs item #1180237, was opened at 2005-04-10 17:20 Message generated for change (Comment added) made by birkenfeld You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1180237&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.3 >Status: Closed >Resolution: Invalid Priority: 5 Submitted By: Eelco (eternia) Assigned to: Nobody/Anonymous (nobody) Summary: Python keeps file references after calling close methode Initial Comment: I found this bug using a python script that: - first mounts a partition (os.system("mount") etc) - change a few files on this partition (f = open (); f.write; f.close) - umounts the partition (os.system("umount") etc) Strangely, the umount didn't work because of a filesystem busy error. Using fuser and lsof i traced this being busy back to the script itself. This is strange behavior because after changing the files on the mounted partition the close method was called which should close all references to the file on the partition. Finally the solution was to do f = 0. So if python has closed a file on a mount a open reference to that file will keep to exist until the script has ended or until the file object is nullified. ---------------------------------------------------------------------- >Comment By: Reinhold Birkenfeld (birkenfeld) Date: 2005-06-26 22:39 Message: Logged In: YES user_id=1188172 I think so too and close this as Invalid. That the resources were freed when the file object was cleaned up shows that the submitter must have made a mistake since the destructor executes exactly the same code as close(). ---------------------------------------------------------------------- Comment By: Ilya Sandler (isandler) Date: 2005-06-26 22:01 Message: Logged In: YES user_id=971153 I also failed to reproduce the problem with a recent Python build on Debian (python session at the bottom) Suggest closing the bug. bagira:~/python> dist/src/python Python 2.5a0 (#18, Jun 2 2005, 17:12:48) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.system("mount /floppy") 0 >>> f=open("/floppy/test","w") >>> f.write('abcd') >>> f.close() >>> os.system('umount /floppy') 0 ---------------------------------------------------------------------- Comment By: Jeff Epler (jepler) Date: 2005-04-14 21:50 Message: Logged In: YES user_id=2772 I tried but can't reproduce this problem. After mounting a filesystem on /mnt/tmp, I ran the following in an interactive session: >>> f = open("/mnt/tmp/x", "w") >>> f.write("testing") >>> f.close() >>> import os; os.system("umount /mnt/tmp") 0 Did you write 'f.close()' or 'f.close'? The former closes the file, but the latter is a statement which has no effect. When you later executed 'f=0', the reference count of the-old-value-of-f dropped to 0 and the file was close()d impliclty. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1180237&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com