def usage_for_queryset(self, queryset, counts=False, min_count=None):
        
        if getattr(queryset.query, 'get_compiler', None):
            # Django 1.2 and up compatible (multiple databases)
            compiler = queryset.query.get_compiler(using='default')
            extra_joins = ' '.join(compiler.get_from_clause()[0][1:])
            where, params = queryset.query.where.as_sql(compiler.quote_name_unless_alias, compiler.connection)
        else:
            # Django 1.1 and down compatible (single database)
            extra_joins = ' '.join(queryset.query.get_from_clause()[0][1:])
            where, params = queryset.query.where.as_sql()
        
        # extra_joins = ' '.join(
        #  queryset.query.get_compiler(using='default').get_from_clause()[0][1:])
        # where, params = queryset.query.where.as_sql()
        if where:
            extra_criteria = 'AND %s' % where
        else:
            extra_criteria = ''
        return self._get_usage(queryset.model, counts, min_count, 
                                extra_joins, extra_criteria, params)
Wait for & dispatch events from native thread
dataset/ETHPy150Open callowayproject/django-supertagging/supertagging/models.py/SuperTagManager.usage_for_queryset--crossover with--dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/virt/libvirt/host.py/Host._dispatch_events