def _geocode(self, address, restriction=''):
        geocoder = None
        format_string = self.get_format_string(restriction)
        query = to_utf((format_string % address).lower())

        if not query:
            return []

        if query in self.cache:
            try:
                return pickle.loads(self.cache[query])
            except:
                pass
        
        if re_addr2.search(address) and restriction:
            rand = random.random()
            if rand < 0.4:
                geocoder = geocoders.Yahoo(settings.YAHOO_APPID)
            elif rand < 0.8:
                geocoder = geocoders.Bing(settings.BING_APIKEY)
            else:
                geocoder = geocoders.GeocoderDotUS()
        else:
            geocoder = geocoders.GeoNames()

        try:
            result = geocoder.geocode(query, exactly_one=False)
            self.ncalls += 1
        except:
            try:
                geocoder = geocoders.Google()
                result = geocoder.geocode(query, exactly_one=False)
                self.ncalls += 1
            except:
                result = []

        self.cache[query] = pickle.dumps(result)
        return result
Lock a server instance.
dataset/ETHPy150Open sirrice/dbtruck/dbtruck/analyze/geocode.py/DBTruckGeocoder._geocode--crossover with--dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/lock_server.py/LockServerController._lock