You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I apologize, this is really a question and not an issue, but I can't seem to figure out if it's possible to spawn more than one worker thread using microjob.
I'm trying something like the following:
import{job,start,stop}from'microjob';(async()=>{try{// start the worker poolawaitstart();// this function will be executed in another threadconstjobA=job(()=>{console.log(`Worker ${process.pid} started`);});// this function should be executed in yet another threadconstjobB=job(()=>{console.log(`Worker ${process.pid} started`);});awaitPromise.all(jobA,jobB);}catch(err){console.error(err);}finally{// shutdown worker poolawaitstop();}})();
Every time I try something like this though, both worker threads console.log the exact same pid value. Am I doing something wrong? Or is this just a limitation with microjob?
The text was updated successfully, but these errors were encountered:
@andycorm microjob is using worker_threads internally so it does not deal with multiple processes. You may be confusing worker_threads with child_process
I apologize, this is really a question and not an issue, but I can't seem to figure out if it's possible to spawn more than one worker thread using microjob.
I'm trying something like the following:
Every time I try something like this though, both worker threads
console.log
the exact samepid
value. Am I doing something wrong? Or is this just a limitation with microjob?The text was updated successfully, but these errors were encountered: