Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/26/12 11:12:57 (11 years ago)
Author:
ascheibe
Message:

#1950

  • added more aggressive locking so that the views don't read run collections that get modified in the meantime
  • start downloading of tasks after the job has been uploaded completely
  • fixed exceptions that got thrown when waiting for the threads that upload the tasks
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r8914 r8939  
    294294        cancellationToken.ThrowIfCancellationRequested();
    295295
     296        // upload tasks
     297        refreshableJob.Progress.Status = "Uploading tasks...";
     298
     299        var tasks = new List<TS.Task>();
     300        foreach (HiveTask hiveTask in refreshableJob.HiveTasks) {
     301          var task = TS.Task.Factory.StartNew((hj) => {
     302            UploadTaskWithChildren(refreshableJob.Progress, (HiveTask)hj, null, resourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, refreshableJob.Job.IsPrivileged, cancellationToken);
     303          }, hiveTask);
     304          task.ContinueWith((x) => refreshableJob.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted);
     305          tasks.Add(task);
     306        }
     307        TS.Task.WaitAll(tasks.ToArray());
     308      }
     309      finally {
    296310        refreshableJob.RefreshAutomatically = true;
    297311        refreshableJob.StartResultPolling();
    298 
    299         // upload tasks
    300         refreshableJob.Progress.Status = "Uploading tasks...";
    301 
    302         var tasks = new List<TS.Task>();
    303         foreach (HiveTask hiveTask in refreshableJob.HiveTasks) {
    304           tasks.Add(TS.Task.Factory.StartNew((hj) => {
    305             UploadTaskWithChildren(refreshableJob.Progress, (HiveTask)hj, null, resourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, refreshableJob.Job.IsPrivileged, cancellationToken);
    306           }, hiveTask)
    307           .ContinueWith((x) => refreshableJob.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
    308         }
    309         try {
    310           TS.Task.WaitAll(tasks.ToArray());
    311         }
    312         catch (AggregateException ae) {
    313           if (!ae.InnerExceptions.All(e => e is TaskCanceledException)) throw ae; // for some reason the WaitAll throws a AggregateException containg a TaskCanceledException. i don't know where it comes from, however the tasks all finish properly, so for now just ignore it
    314         }
    315312        refreshableJob.Job.Modified = false;
    316       }
    317       finally {
    318313        refreshableJob.IsProgressing = false;
    319314        refreshableJob.Progress.Finish();
     
    405400        var tasks = new List<TS.Task>();
    406401        foreach (HiveTask child in hiveTask.ChildHiveTasks) {
    407           tasks.Add(TS.Task.Factory.StartNew((tuple) => {
     402          var task = TS.Task.Factory.StartNew((tuple) => {
    408403            var arguments = (Tuple<HiveTask, HiveTask>)tuple;
    409404            UploadTaskWithChildren(progress, arguments.Item1, arguments.Item2, groups, taskCount, totalJobCount, configPluginId, jobId, log, isPrivileged, cancellationToken);
    410           }, new Tuple<HiveTask, HiveTask>(child, hiveTask))
    411           .ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
     405          }, new Tuple<HiveTask, HiveTask>(child, hiveTask));
     406          task.ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted);
     407          tasks.Add(task);
    412408        }
    413409        taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall!
    414         try {
    415           TS.Task.WaitAll(tasks.ToArray());
    416         }
    417         catch (AggregateException ae) {
    418           if (!ae.InnerExceptions.All(e => e is TaskCanceledException)) throw ae; // for some reason the WaitAll throws a AggregateException containg a TaskCanceledException. i don't know where it comes from, however the tasks all finish properly, so for now just ignore it
    419         }
     410        TS.Task.WaitAll(tasks.ToArray());
    420411      }
    421412      finally {
Note: See TracChangeset for help on using the changeset viewer.