Concurrent CopyAsync issues
I have some code to copy a set of folders across from a set of source folders in a loop that works, but fails if I start copying a whole bunch of folders across concurrently. What happens is Box will randomly fail to create some of the folders, failing in different places each time. It will do this consistently every time, even if just 2 projects are run together.
The failing code is almost straight out of the Box documentation
var items = await client.FoldersManager.GetFolderItemsAsync(copyFromId, 500);
foreach (var e in items.Entries)
{
if (e.GetType() == typeof(Box.V2.Models.BoxFolder))
{
var requestParams = new BoxFolderRequest()
{
Id = e.Id,
Parent = new BoxRequestEntity()
{
Id = copyToId
}
};
//Failing line
await client.FoldersManager.CopyAsync(requestParams);
}
}
The error it returns is “The operation is blocked by another on-going operation”. I've tried handling the exception and retrying it (and this is also what the box documentation suggests here https://developer.box.com/guides/api-calls/permissions-and-errors/common-errors/ ) I implemented a retry policy where it retries 10 times at every x amount of seconds:
await _retryPolicy.ExecuteAsync(() => client.FoldersManager.CopyAsync(requestParams));
but the code never retries after the first failure (and I’ve tried a variety of less elegant solutions blunt such as while loops with the same result), because once the exception is raised the thread seems to stop and then gets killed. The only solution left is some sort of linear queuing mechanism, but I'm hoping it isn't so. Anyone else with any similar issues?
投稿コメントは受け付けていません。
コメント
0件のコメント