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
parent got message the worker is sending this
worker got message response from parent to the worker is sending this
However, when I introduce Piscina, the worker thread never gets the message from parent:
// parent-piscina.jsconstPiscina=require('piscina');const{ MessageChannel }=require('worker_threads');constpiscina=newPiscina({filename: require.resolve('./piscina-message-demo-worker'),});constchannel=newMessageChannel();channel.port2.on('message',(message)=>{console.log('parent got:',message);channel.port2.postMessage('response from parent');});piscina.runTask({port: channel.port1},[channel.port1]);
// piscina-message-demo-worker.jsmodule.exports=({ port })=>{port.once('message',(val)=>console.log('worker got',val));port.postMessage('hello from the worker pool');};
You’ll want useAtomics: false if you plan to communicate with the worker thread externally, instead of using piscina’s built-in communication mechanism.
It’s going to be a bit slower in that case, but that’s probably fine.
When I use
worker_threads
directly, I'm able to set up a bidirectional communication between the parent and workers:On Node 14, this produces:
However, when I introduce Piscina, the worker thread never gets the message from parent:
On Node 14, this hangs at:
Am I doing this wrong?
Possibly related: #133
The text was updated successfully, but these errors were encountered: