javascript - Calling setTimeout from child process (NodeJS) -


I would like to call a function via setTimeout, which can be removed before setTimeout using a hair process.

1) I think that if the child calls the procedure function (even if it is defined externally), then the set-end will be canceled if the child goes out of the process is it right? 2) If so, is it possible that the basic process is to be indicated to execute the setmate instead of the child's procedure, or is there a better way of achieving it?

Thank you!

I'm not sure that I fully understand, but provide some potentially applicable link And examples.

It is possible to send and receive messages between the master and child process, with which the child_process module and part of the cluster. For example, clearing setTimeout when the child's process sends a message to the master:

  var cp = is required ('child_process'); Var child = cp.fork (__DERNAM + '/sub.js'); Var timer = set timeout (function () {console.log ('timeout');}, 5000); Child.on ('Message', Function (msg) {console.log (msg); Clear Timeout;});  

child

  setTimeout (function () {console.log ('Finishing a Long Working'); process.send ({status: Done '});}, 3000); / /> 

P>


Comments