Closed ghostlexly closed 1 year ago
I want to override the .exec function on workerpool but it's calls my console.log twice, can't figure out why :
export const queues = workerpool.pool({ maxWorkers: require("os").cpus().length, }); const originalExec = queues.exec; queues.exec = function (method, params, options) { console.log("task started"); return originalExec.call(queues, method, params, options); };
Tryed to change the "this" argument on the call, also the .apply() function, the results are the same.
The exec method can indeed call itself:
https://github.com/josdejong/workerpool/blob/8219f7deaf535310cb8c3f273cda8e047959502c/src/Pool.js#L143-L146
I guess you can just write a wrapper function (or object) and invoke that instead of replacing the original method?
Okay, i will wrap it. Thanks for your reply.
I want to override the .exec function on workerpool but it's calls my console.log twice, can't figure out why :
Tryed to change the "this" argument on the call, also the .apply() function, the results are the same.