worker functions use promises for async
This commit is contained in:
@@ -118,10 +118,7 @@ export default class Job extends events.EventEmitter {
|
|||||||
this.debug(`Starting job ${job._id}`);
|
this.debug(`Starting job ${job._id}`);
|
||||||
|
|
||||||
const workerOutput = new Promise((resolve, reject) => {
|
const workerOutput = new Promise((resolve, reject) => {
|
||||||
this.workerFn.call(null, job._source.payload, function (err, cbOutput) {
|
resolve(this.workerFn(job._source.payload));
|
||||||
if (err) return reject(err);
|
|
||||||
resolve(cbOutput);
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
reject(new WorkerTimeoutError({
|
reject(new WorkerTimeoutError({
|
||||||
|
|||||||
Reference in New Issue
Block a user