[Pywikipedia-l] [ pywikipediabot-Bugs-2009068 ] diskcache files could be deleted when bot finishes

SourceForge.net noreply at sourceforge.net
Sat Jul 5 10:53:55 UTC 2008


Bugs item #2009068, was opened at 2008-07-02 20:39
Message generated for change (Comment added) made by nicdumz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2009068&group_id=93107

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: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Melancholie (melancholie)
Assigned to: Nobody/Anonymous (nobody)
Summary: diskcache files could be deleted when bot finishes

Initial Comment:
Currently, using diskcache, cache files are created in the folder "cache". But they do not get deleted on proper exits. If you run the bot once more, a new cache file (for each wiki) is created:

1st run: msg-wikipedia-eo-wpovcxkn
2nd run: msg-wikipedia-eo-oqxakgvsy
etc.

When the bot finishes, all current *cache* files (c|sh)ould be deleted.

----------------------------------------------------------------------

>Comment By: NicDumZ  Nicolas Dumazet (nicdumz)
Date: 2008-07-05 12:53

Message:
Logged In: YES 
user_id=1963242
Originator: NO

Yes __del__ is not guaranteed to be called everytime, and we should not
rely on it to do this kind of operations : __del__ is called on an object
only when its reference counts goes to zero. And here, our cache object is
referenced by our Site objects, which are referenced... barely everywhere,
and yes, in some special cases, we might have a reference cycle, preventing
the __del__ call : the memory is freed, in the C layer, but __del__ is not
called.

I renamed __del__ to delete() and added a call in stopme() in r5670. If
this bug happens again, we'll have to double check for final calls to
stopme() in our scripts :) 


----------------------------------------------------------------------

Comment By: Bryan (btongminh)
Date: 2008-07-02 21:37

Message:
Logged In: YES 
user_id=1806226
Originator: NO

Really strange that that destructor does not work. Perhaps add this
function to wikipedia.stopme() ?

----------------------------------------------------------------------

Comment By: Francesco Cosoleto (cosoleto)
Date: 2008-07-02 21:28

Message:
Logged In: YES 
user_id=181280
Originator: NO

I consider this a bug report, not a feature request because that it's
expected behaviour.

diskcache.py:

    def __del__(self):
        self.cache_file.close()
        import os
        os.unlink(self.cache_path)
        os = None

os.unlink() delete the file (http://docs.python.org/lib/os-file-dir.html).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2009068&group_id=93107



More information about the Pywikipedia-l mailing list