Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Gspread-更改侦听器?_Python_Gspread - Fatal编程技术网

Python Gspread-更改侦听器?

Python Gspread-更改侦听器?,python,gspread,Python,Gspread,我目前运行一个守护进程线程,它获取所有单元格值,计算是否有更改,然后在循环中写出依赖单元格,即: def f(): while not event.is_set(): update() event.wait(15) Thread(target=f).start() 这是可行的,但是循环get-all调用是重要的I/O 如果Google Sheets通知线程更改,那么就不会这样做了。有什么方法可以做到这一点吗?我对gspread GitHub的问题进行了重

我目前运行一个守护进程线程,它获取所有单元格值,计算是否有更改,然后在循环中写出依赖单元格,即:

def f():
    while not event.is_set():
        update()
        event.wait(15)
Thread(target=f).start()
这是可行的,但是循环get-all调用是重要的I/O

如果Google Sheets通知线程更改,那么就不会这样做了。有什么方法可以做到这一点吗?

我对gspread GitHub的问题进行了重新表述:

在应用程序脚本的帮助下,可以从Google Sheets获取更改通知。您可以在脚本编辑器中设置自定义函数,并为此函数分配触发器事件。在此函数中,您可以使用获取外部url

在侦听端(您的web服务器),您将拥有此url的处理程序。此处理程序将执行此任务。根据服务器配置(许多线程或进程),确保避免可能的争用情况


此外,我还没有测试非浏览器触发的更新。如果Sheets为这种类型的更新触发相同的事件,则可能会出现无限循环。

每当Google Sheets检测到更改时,我都可以通过触发HTTP请求来实现这一点

在谷歌网页上:

function onEdit (e) {
  UrlFetchApp.fetch("http://myaddress.com");
}
Python侧(带龙卷风)

导入tornado.ioloop
导入tornado.web
类MainHandler(tornado.web.RequestHandler):
def get(自我):
关于_edit()
self.write('更新')
_edit()上的定义:
#代码在这里
通过
app=tornado.web.Application([(r'/',MainHandler)])
应用程序侦听(此处为端口)
tornado.ioloop.ioloop.current().start()
我不认为这种功能应该在gspread的范围内,但我希望文档能够帮助其他人