fix lock if no mapupdates exist
@@ -95,7 +95,12 @@ class MapUpdate(models.Model):
@contextmanager
def lock(cls):
with transaction.atomic():
- yield cls.objects.select_for_update().get(pk=cls.objects.earliest().pk)
+ try:
+ earliest = cls.objects.earliest()
+ except cls.DoesNotExist:
+ yield
+ else:
+ yield cls.objects.select_for_update().get(pk=earliest.pk)
def _changed_geometries_filename(self):
return os.path.join(settings.CACHE_ROOT, 'changed_geometries', 'update_%d.pickle' % self.pk)
