@classmethod
    def _lookup_field(cls, document, fields):
        if isinstance(fields, (tuple, list)):
            return [document._meta.get_field_by_name((field == "pk" and "id") or field)[0] for field in fields]
        return document._meta.get_field_by_name((fields == "pk" and "id") or fields)[0]
Test cases where multiple agents are racing to acquire locks.
dataset/ETHPy150Open aparo/django-elasticsearch/django_elasticsearch/manager.py/QuerySet._lookup_field--crossover with--dataset/ETHPy150Open viewfinderco/viewfinder/backend/db/test/lock_test.py/LockTestCase.testRaceToAcquire