Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task doesn't fire when changing concurrencey config between taskgroups and sub taskgroups. #6

Closed
crito opened this issue Nov 20, 2013 · 2 comments

Comments

@crito
Copy link
Contributor

crito commented Nov 20, 2013

In the following example:

var group = new TaskGroup();

group.setConfig({concurrency: 1});

group.addTask(function () {
  console.log('Running first task outside of group.');
});

// Add a sub-group to our exiting group
group.addGroup(function(){
  // Tell this sub-group to execute in parallel (all at once) by setting its
  // concurrency to unlimited by default the concurrency for all groups is set
  // to 1 which means that they execute in serial fashion (one after the other,
  // instead of all at once)
  this.setConfig({concurrency: 0});

  // Add an asynchronous task that gives its result to the completion callback
  this.addTask(function(complete){
    setTimeout(function(){
      console.log('Running asynchronous task in group.')
    },500);
  });

  // Add a synchronous task that returns its result
  this.addTask(function(){
    console.log("Running synchronous task in group.")
  });
});

group.addTask(function () {
  console.log('Running second task outside of group.');
});

group.run()

I get the following result:

Running first task outside of group.
Running synchronous task in group.
Running asynchronous task in group.

The second task outside of the group is not fired. If I configure the concurrency of the task group to 0 instead of 1, it does fire as expected.

@balupton
Copy link
Member

So the problem is actually a documentation problem!

  // Add an asynchronous task that gives its result to the completion callback
  this.addTask(function(complete){
    setTimeout(function(){
      console.log('Running asynchronous task in group.')
    },500);
  });

Doesn't call the completion callback! Therefore it hangs there.

I've created #7 for a possible way of detecting such problems.

@crito
Copy link
Contributor Author

crito commented Nov 23, 2013

I added a note about this in the new usage docs I sent you with #9. But its still something that is really easy to overlook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants