Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bull

Package Overview
Dependencies
Maintainers
1
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bull - npm Package Compare versions

Comparing version 3.3.0 to 3.3.1

9

CHANGELOG.md

@@ -0,5 +1,12 @@

v.3.3.1
=======
- Fixed #714
[Changes](https://github.com/OptimalBits/bull/compare/v3.3.0...v3.3.1)
v.3.3.0
=======
- Added a method ```Queue##removeRepeatable``` to remove repeatable jobs.
-
- Now also emits drained as a global event.
- Fixed #518, #624

@@ -6,0 +13,0 @@ [Changes](https://github.com/OptimalBits/bull/compare/v3.2.0...v3.3.0)

99

lib/process/child-pool.js

@@ -0,53 +1,72 @@

'use strict';
var fork = require('child_process').fork;
var path = require('path');
var pool = {};
var Promise = require('bluebird');
module.exports.retain = function(processFile){
return new Promise(function(resolve, reject) {
var keys = Object.keys(pool);
for(var i=0; i<keys.length; i++){
var child = pool[keys[i]];
if(!child.retained){
child.retained = true;
return resolve(child.subprocess);
module.exports = function ChildPool() {
if(!(this instanceof ChildPool)){
return new ChildPool();
}
var retained = {};
var free = [];
this.retain = function(processFile){
return new Promise(function(resolve, reject) {
var child = free.pop();
if(child){
return resolve(child);
}
}
try{
var child = fork(path.join(__dirname, './master.js'));
try{
var child = fork(path.join(__dirname, './master.js'));
child.on('exit', function(code, signal){
console.error('Child process exited', child.pid, code, signal);
delete pool[child.pid];
});
retained[child.id];
pool[child.pid] = {
subprocess: child,
retained: true
};
child.on('exit', function(code, signal){
console.error('Child process exited', child.pid, code, signal);
child.send({
cmd: 'init',
value: processFile
}, function() {
resolve(child);
});
}catch(err){
reject(err);
// Remove exited child
deleteChild(child);
function deleteChild(child){
delete retained[child.pid];
var childIndex = free.indexOf(child);
if (childIndex > -1) {
free.splice(childIndex, 1);
}
}
});
child.send({
cmd: 'init',
value: processFile
}, function() {
resolve(child);
});
} catch(err){
reject(err);
}
});
};
this.release = function(child){
delete retained[child.pid];
free.push(child);
};
this.clean = function(){
var keys = Object.keys(retained);
for(var i=0; i<keys.length; i++){
retained[keys[i]].kill();
}
});
};
retained = {};
module.exports.release = function(child){;
pool[child.pid].retained = false;
for(var i=0; i<free.length; i++){
free[i].kill();
}
free = [];
};
};
module.exports.clean = function(){
var keys = Object.keys(pool);
for(var i=0; i<keys.length; i++){
pool[keys[i]].subprocess.kill();
delete pool[keys[i]];
}
};

@@ -0,5 +1,6 @@

'use strict';
var Promise = require('bluebird');
var childPool = require('./child-pool');
module.exports = function(processFile){
module.exports = function(processFile, childPool){
return function process(job){

@@ -6,0 +7,0 @@ return childPool.retain(processFile).then(function(child){

@@ -489,3 +489,3 @@ /*eslint-env node */

}).finally(function(){
require('./process/child-pool').clean();
_this.childPool && _this.childPool.clean();
_this.closed = true;

@@ -567,4 +567,5 @@ });

if(typeof handler === 'string'){
this.childPool = this.childPool || require('./process/child-pool')();
var sandbox = require('./process/sandbox');
this.handlers[name] = sandbox(handler).bind(this);
this.handlers[name] = sandbox(handler, this.childPool).bind(this);
} else {

@@ -571,0 +572,0 @@ handler = handler.bind(this);

{
"name": "bull",
"version": "3.3.0",
"version": "3.3.1",
"description": "Job manager",

@@ -5,0 +5,0 @@ "main": "./lib/queue",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc