找到你要的答案

Q:Asynchronous way to listen web service for data change

Q:异步方式监听Web服务的数据更改

I am new to python. I want to read JSON data from URL and if there is any change in JSON data on server, I want to update in my JSON file which is on client. How can I do that through python?

Actually i am ploting graph on django using JSON data which is on another server. That JSON data is updated frequently. So here i want to update my charts based on updated json data. For that i has to listen to URL link for change. So how can i do that.....i know with select() system call i can but need some another way

我是新来的蟒蛇。我想从URL,如果在服务器上的JSON数据的任何改变读取JSON数据,我想在我的JSON文件是客户端更新。我怎么能通过Python?

其实我是绘图图被使用JSON数据,另一台服务器上的。JSON数据是经常更新的。所以在这里我要更新我的图表的基础上更新的JSON数据。因为我要听网址链接的变化。那么我该怎么做,我知道..... select()系统调用可以但需要另一种方式

answer1: 回答1:

There's no way to "listen" for changes other than repeatedly requesting that URL to check if something has changed; i.e. classic "pull updates". To get actual live notifications of changes, that other server needs to offer a way to push such a notification to you. If it's just hosting the file and is not offering any active notifications of any sort, then repeatedly asking is the best you can do. Try not to kill the server when doing so.

没有办法“听”的变化,而不是重复请求的URL,以检查是否有什么改变,即经典的“拉更新”。要获得实际的通知的变化,其他服务器需要提供一种方式来推动这样的通知给你。如果它只是托管文件,并没有提供任何积极的通知任何形式,然后反复询问是最好的,你可以做。尝试不要杀死服务器时,这样做。

python