Sometimes a resource is locked
ProSerg opened this issue · 2 comments
Thanks for your project.
Could you advice me, please?
There are jobs that carried out in parallel for uploading files to yandex disk in my pipeline.
Sometimes, I get error ResourceIsLockedError.
I researched the documents, there finded this parameters:
timeout – float or tuple, request timeout
headers – dict or None, additional request headers
n_retries – int, maximum number of retries
retry_interval – delay between retries in seconds
How I can use them for away issue?
Thanks!
As far as I know, ResourceIsLockedError
occurs when there are multiple conflicting operations on the same resource. You should probably just try uploading files again after you got the error.
Automatic retries are only carried out for random errors that are typically the server's fault (such as an InternalServerError
). ResourceIsLockedError
does not seem to fall into this category.
You can do something like this:
import yadisk
ynd = yadisk.YaDisk(...)
...
while True:
try:
ynd.upload(...) # Upload your file
break
except yadisk.exceptions.ResourceIsLockedError:
# Try again
continue
Thanks a lot! 👍