Skip to content

fix(pool): added optional setting for killing processes and not retaining them#1173

Open
dawiss1337 wants to merge 5 commits into
OptimalBits:developfrom
dawiss1337:master
Open

fix(pool): added optional setting for killing processes and not retaining them#1173
dawiss1337 wants to merge 5 commits into
OptimalBits:developfrom
dawiss1337:master

Conversation

@dawiss1337

Copy link
Copy Markdown

Created optional setting for child pool, default is set to true - always retains child processes, but when set to false the child process is killed and not retained after finishing processing.

@dawiss1337

Copy link
Copy Markdown
Author

@manast would appreciate if you could take a look at this PR

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.06%) to 93.789% when pulling ac446e4 on DavisJaunzems:master into 40a69ac on OptimalBits:develop.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.06%) to 93.789% when pulling ac446e4 on DavisJaunzems:master into 40a69ac on OptimalBits:develop.

@coveralls

coveralls commented Jan 14, 2019

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.01%) to 93.836% when pulling 2b5bfdc on DavisJaunzems:master into 40a69ac on OptimalBits:develop.

@manast

manast commented Jan 17, 2019

Copy link
Copy Markdown
Member

@DavisJaunzems sorry for the late response. It has been a hectic week so far.

Comment thread lib/job.js

_opts.attempts = typeof _opts.attempts == 'undefined' ? 1 : _opts.attempts;
_opts.delay = typeof _opts.delay == 'undefined' ? 0 : _opts.delay;
_opts.delay = typeof _opts.delay == 'undefined' ? 0 : Number(_opts.delay);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fix seems to have been slipped in from an unrelated issue.

Comment thread test/test_child-pool.js Outdated

return pool.retain(processor).then(function(_child) {
expect(_child).to.be.ok;
child = _child;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this assignment?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must have been from copy-paste, you are right no need for re-assigned the variable, could pool.release(_child); directly

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated PR, removed the unnecessary reassignment

Comment thread lib/process/child-pool.js Outdated
this.free = {};
};

ChildPool.prototype.setKeepProcesses = function(keepProcesses) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking that it would be better to change the name to a more explanatory: setReuseProcesses or similar.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed the methods and variables in the latest PR

Comment thread lib/queue.js Outdated
this.getJobFromId = Job.fromId.bind(null, this);

// Check settings to see if processes will be kept after finishing processing, default set to true
this.keepProcesses =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are setting a default value true a few lines above, this is not necessary.

Comment thread lib/queue.js Outdated
});
};

Queue.prototype.setKeepProcesses = function(keepProcesses) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need a setter for this setting, as with the other settings.

@dawiss1337

Copy link
Copy Markdown
Author

The latest commit has changed method and variable names, and removed redundant code @manast

@manast

manast commented Jan 21, 2019

Copy link
Copy Markdown
Member

There are 3 format issues preventing the tests from running:

/home/travis/build/OptimalBits/bull/test/test_child-pool.js
  145:74  error  Unexpected function expression            prefer-arrow-callback
  146:5   error  Unexpected var, use let or const instead  no-var
  150:40  error  Unexpected function expression            prefer-arrow-callback

@dawiss1337

Copy link
Copy Markdown
Author

@manast what command did you run to get these errors, because I can run all of the tests locally?
Also looking at the format issues (using let or const instead of var and using arrow functions), all of the tests should have the same formatting issues..

@manast

manast commented Jan 30, 2019

Copy link
Copy Markdown
Member

@DavisJaunzems The command that you can run locally:
npm run prettier -- --list-different

@dawiss1337

Copy link
Copy Markdown
Author

@manast updated the code, anything else before this can be merged?

@ks-s-a

ks-s-a commented Aug 20, 2019

Copy link
Copy Markdown

The PR was spoiled, but the feature is good. @manast may it be merged for the next release?

@manast

manast commented Aug 20, 2019

Copy link
Copy Markdown
Member

In order to merge this we need to rework it according to the comments and make it pass the tests.

@stale

stale Bot commented Jul 12, 2021

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix label Jul 12, 2021
@stale stale Bot removed the wontfix label Jul 15, 2021
@manast manast added the pinned label Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants