Пример #1
0
        public override async Task PerformTask(ISkraprWorker worker)
        {
            worker.Logger.LogDebug("{taskName} Started processing subtasks.", Name);

            foreach (var task in Tasks)
            {
                await worker.ProcessSkraprTask(task);
            }

            worker.Logger.LogDebug("{taskName} Completed processing subtasks.", Name);
        }
Пример #2
0
        private async Task ProcessNodeTask(Tuple <long, IList <ISkraprTask> > nodeTask, ISkraprWorker worker, ActionBlock <Tuple <long, IList <ISkraprTask> > > subTaskFlow)
        {
            worker.Logger.LogDebug("{taskName} Started processing subtasks for nodeId {nodeId}", Name, nodeTask.Item1);

            try
            {
                foreach (var task in nodeTask.Item2)
                {
                    await worker.ProcessSkraprTask(task);
                }
            }
            catch (Exception ex) when(ex is AssertionFailedException || ex is NavigationFailedException)
            {
                //Add it back into the queue.
                subTaskFlow.Post(nodeTask);
            }
            catch (Exception ex) when(ex is OperationCanceledException || ex is TaskCanceledException)
            {
                worker.Logger.LogWarning("{taskName} is terminating due to a cancellation request.", Name);
                throw;
            }
            catch (Exception ex)
            {
                worker.Logger.LogError("{taskName} An unhandled exception occurred processing subtasks for nodeId {nodeId}: {exception}", Name, nodeTask.Item1, ex);
                throw;
            }

            worker.Logger.LogDebug("{taskName} Completed processing subtasks for nodeId {nodeId}", Name, nodeTask.Item1);

            if (subTaskFlow.InputCount == 0)
            {
                subTaskFlow.Complete();
            }

            worker.Logger.LogDebug("{taskName} {count} nodes remaining", Name, subTaskFlow.InputCount);
        }