NodeJs how to create a non-blocking computation

前端 未结 5 1695
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 01:53

I am trying to get my head around creating a non-blocking piece of heavy computation in nodejs. Take this example (stripped out of other stuff):

http.createS         


        
5条回答
  •  情深已故
    2020-12-10 02:30

    You can't do that directly, without using some of the IO modules in node (such as fs or net). If you need to do a long-running computation, I suggest you do that in a child process (e.g. child_process.fork) or with a queue.

提交回复
热议问题