【发布时间】:2015-08-28 15:23:00
【问题描述】:
我有以下问题:
我有一个 python 脚本和一个在我的机器上运行的 socket.io 服务器。 现在,我想将 python 脚本中的数据传递给服务器和客户端。 目前,我正在使用以下内容:
服务器:
fs.watchFile('position.txt', function (curr, prev) {
//console.log('the current mtime is: ' + curr.mtime);
//console.log('the previous mtime was: ' + prev.mtime);
io.emit('positionswechsel', curr.mtime); //need the content of the file here
});
Python:
def my_callback2(channel):
fout=open("../sio/position.txt","w")
fout.write("P1")
fout.close()
print "falling edge detected on 18"
在这个解决方案中,我发现事件(写入文件)和服务器的反应之间的延迟非常高。
现在,我认为应该有一种方法可以将信息从 python 脚本直接传递到服务器/客户端(我想在网页上看到更改)。
有人请帮帮我吗?
亚尼克
【问题讨论】: