def check_instance_links(sender, instance, linklist_cls=linklist_cls, **kwargs):
        
        def do_check_instance_links(sender, instance, linklist_cls=linklist_cls, wait=False):
            # On some installations, this wait time might be enough for the
            # thread transaction to account for the object change (GH #41).
            # A candidate for the future post_commit signal.
            if wait:
                time.sleep(0.1)
            with update_lock:
                content_type = linklist_cls.content_type()
                new_links = []
                old_links = Link.objects.filter(content_type=content_type, object_id=instance.pk)

                linklists = linklist_cls().get_linklist(extra_filter={'pk':instance.pk,})

                if not linklists:
                    # This object is no longer watched by linkcheck according to object_filter
                    links = []
                else:
                    linklist = linklists[0]
                    links = linklist['urls']+linklist['images']
                    
                for link in links:
                    # url structure = (field, link text, url)
                    url = link[2]
                    internal_hash = False
                    if url.startswith('#'):
                        internal_hash = url
                        url = instance.get_absolute_url() + url
                    u, created = Url.objects.get_or_create(url=url)
                    l, created = Link.objects.get_or_create(url=u, field=link[0], text=link[1], content_type=content_type, object_id=instance.pk)
                    new_links.append(l.id)
                    u.still_exists = True
                    if internal_hash:
                        setattr(u, '_internal_hash', internal_hash)
                        setattr(u, '_instance', instance)
                    u.check_url()
                    
                gone_links = old_links.exclude(id__in=new_links)
                gone_links.delete()

        # Don't run in a separate thread if we are running tests
        if len(sys.argv) > 1 and sys.argv[1] == 'test' or sys.argv[0] == 'runtests.py':
            do_check_instance_links(sender, instance, linklist_cls)
        else:
            t = Thread(target=do_check_instance_links, args=(sender, instance, linklist_cls, True))
            t.start()
When an object is saved:
dataset/ETHPy150Open DjangoAdminHackers/django-linkcheck/linkcheck/listeners.py/check_instance_links