Use tenancity to backoff when layer is locked
Rather than doing a while loop and sleep, let's use tenancity to do an exponential backoff off when the layer is already being fetched by another process. Change-Id: I47c9a2693d831958958fa6ea7cccbdd8fdb12277
This commit is contained in:
committed by
Bogdan Dobrelya
parent
1c9b4a223e
commit
98f2d962f9
@@ -31,7 +31,6 @@ import subprocess
|
||||
import tempfile
|
||||
import tenacity
|
||||
import threading
|
||||
import time
|
||||
import yaml
|
||||
|
||||
from oslo_concurrency import processutils
|
||||
@@ -1128,10 +1127,10 @@ class PythonImageUploader(BaseImageUploader):
|
||||
wait=tenacity.wait_random_exponential(multiplier=1, max=10)
|
||||
)
|
||||
def _layer_fetch_lock(cls, layer):
|
||||
LOG.debug('[%s] Locking layer' % layer)
|
||||
while layer in cls.uploader_lock_info:
|
||||
if layer in cls.uploader_lock_info:
|
||||
LOG.debug('[%s] Layer is being fetched by another thread' % layer)
|
||||
time.sleep(0.5)
|
||||
raise ImageUploaderThreadException('layer being fetched')
|
||||
LOG.debug('[%s] Locking layer' % layer)
|
||||
LOG.debug('[%s] Starting acquire for lock' % layer)
|
||||
with cls.uploader_lock:
|
||||
if layer in cls.uploader_lock_info:
|
||||
|
||||
Reference in New Issue
Block a user