def open_resource(self, resource, mode):
        while 1:
            rule = self.rc_server.get_resource(self.host, self.pid, resource)
            if rule is False: # WE HAVE TO LOCK AND APPLY A RULE...
                rule = self.acquire_rule(resource)
                if rule is True:
                    # Looks like a race condition, wait a minute before
                    # trying again.
                    time.sleep(60)
                    continue
                # Construct the resource.
                return ResourceFile(resource, rule, mode, self)
            elif rule is True:
                # Rule is locked by another processor, wait a minute before
                # trying again.
                time.sleep(60)
            else: # GOT A REGULAR FILE, SO JUST OPEN IT
                return file(rule, mode)
See lfs.plugins.PriceCalculator
dataset/ETHPy150Open cjlee112/pygr/pygr/coordinator.py/Processor.open_resource--crossover with--dataset/ETHPy150Open diefenbach/django-lfs/lfs/catalog/models.py/Product.get_price