zhuyifei1999 closed this task as "Declined".
zhuyifei1999 added a comment.


  This is an instance of cyclic reference. The frame refers to the entry, the 
entry has _getexception, the exception refers to the frame. The exception would 
also definitely reference the inner frame where the exception is instantiated 
and that frame would refer to the outer frame by `f_back`
  
  To prove this is a reference cycle, this works:
  
    import osmium, pywikibot
    import gc
    en_wiki = pywikibot.Site("en", "wikipedia")
    
    class TestHandler(osmium.SimpleHandler):
        def node(self, n):
            print(n.id)
            entry = pywikibot.Page(en_wiki, 'non-existing article or even 
redirect')
            entry.text
            entry.clear_cache()  # Clear cache even works if there is no call 
to `.text`
            del entry
            gc.collect()
    
    h = TestHandler()
    # Download from 
http://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf
    h.apply_file('liechtenstein-latest.osm.pbf')
  
  `gc.collect` would kill unused reference cycles.
  
  osmium should not care about reference cycles. Ask them to perform a GC if 
they suspect values being used referred to outside the function.

TASK DETAIL
  https://phabricator.wikimedia.org/T261162

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: zhuyifei1999
Cc: zhuyifei1999, Aklapper, pywikibot-bugs-list, Stalker, JohnsonLee01, SHEKH, 
Dijkstra, Khutuck, Zkhalido, Viztor, Wenyi, Tbscho, MayS, Mdupont, JJMC89, 
Dvorapa, Altostratus, Avicennasis, mys_721tx, jayvdb, Masti, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to