-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix(pool): added optional setting for killing processes and not retaining them #1173
base: develop
Are you sure you want to change the base?
Conversation
@manast would appreciate if you could take a look at this PR |
1 similar comment
@DavisJaunzems sorry for the late response. It has been a hectic week so far. |
lib/job.js
Outdated
@@ -48,7 +48,7 @@ function setDefaultOpts(opts) { | |||
var _opts = Object.assign({}, opts); | |||
|
|||
_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); |
There was a problem hiding this comment.
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.
test/test_child-pool.js
Outdated
|
||
return pool.retain(processor).then(function(_child) { | ||
expect(_child).to.be.ok; | ||
child = _child; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this assignment?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
lib/process/child-pool.js
Outdated
this.retained = {}; | ||
this.free = {}; | ||
}; | ||
|
||
ChildPool.prototype.setKeepProcesses = function(keepProcesses) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
lib/queue.js
Outdated
@@ -250,6 +251,13 @@ var Queue = function Queue(name, url, opts) { | |||
this.processJob = this.processJob.bind(this); | |||
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 = |
There was a problem hiding this comment.
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.
lib/queue.js
Outdated
@@ -672,6 +680,10 @@ Queue.prototype.start = function(concurrency) { | |||
}); | |||
}; | |||
|
|||
Queue.prototype.setKeepProcesses = function(keepProcesses) { |
There was a problem hiding this comment.
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.
The latest commit has changed method and variable names, and removed redundant code @manast |
There are 3 format issues preventing the tests from running:
|
@manast what command did you run to get these errors, because I can run all of the tests locally? |
@DavisJaunzems The command that you can run locally: |
@manast updated the code, anything else before this can be merged? |
The PR was spoiled, but the feature is good. @manast may it be merged for the next release? |
In order to merge this we need to rework it according to the comments and make it pass the tests. |
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. |
Created optional setting for child pool, default is set to
true
- always retains child processes, but when set tofalse
the child process is killed and not retained after finishing processing.