(节点)警告:检测到可能的EventEmitter内存泄漏。添加了11个消息监听器。使用emitter.setMaxListeners()来增加限制

时间:2016-08-07 15:48:22

标签: python node.js

每当我运行以下代码时,我都会收到错误

(node) warning: possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit.

代码:

function compute() {
     var PythonShell = require('python-shell');
            var options = {
                scriptPath: '/home/pi/projectFinal/nodejsControllingServo/sensorTest'
            };
            var pyshell = new PythonShell('sensor.py',options);
            var eventsEmitter = require("events").EventEmitter;



    pyshell.on('message', function (message) {
                        myValueList [counter] = message;
                        counter=counter+1;
                    });
    pyshell.end(function (err) {
                        if (err) throw err;

                        for ( var i = 4; i < myValueList.length; i++) {
                             console.log ("My value : " + myValueList[i]);   
                    });


    sleep.usleep(5000);
            process.nextTick(compute);
        }
        compute();

什么是可能的解决方案,以便我可以摆脱内存泄漏? 提前致谢

0 个答案:

没有答案