Author serhiy.storchaka
Recipients pablogsal, serhiy.storchaka, shihai1991, terry.reedy, vstinner, zach.ware
Date 2020-09-05.07:38:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1599291506.36.0.960979569162.issue41718@roundup.psfhosted.org>
In-reply-to
Content
You could save/restore this data only when corresponded modules was imported, like it was done in clear_caches() in refleak.py. For example:

    # Same for Process objects
    def get_multiprocessing_process__dangling(self):
        multiprocessing_process = sys.modules.get('multiprocessing.process')
        if not multiprocessing_process:
            return set()
        # Unjoined process objects can survive after process exits
        multiprocessing_process._cleanup()
        # This copies the weakrefs without making any strong reference
        return multiprocessing_process._dangling.copy()
    def restore_multiprocessing_process__dangling(self, saved):
        multiprocessing_process = sys.modules.get('multiprocessing.process')
        if not multiprocessing_process:
            return
        multiprocessing_process._dangling.clear()
        multiprocessing_process._dangling.update(saved)
History
Date User Action Args
2020-09-05 07:38:26serhiy.storchakasetrecipients: + serhiy.storchaka, terry.reedy, vstinner, zach.ware, pablogsal, shihai1991
2020-09-05 07:38:26serhiy.storchakasetmessageid: <1599291506.36.0.960979569162.issue41718@roundup.psfhosted.org>
2020-09-05 07:38:26serhiy.storchakalinkissue41718 messages
2020-09-05 07:38:25serhiy.storchakacreate