简体   繁体   English

在远程服务器上调用python脚本并轮询状态

[英]Invoke a python script on a remote server and poll the status

I'm looking for a best way to invoke a python script on a remote server and poll the status and fetch the output. 我正在寻找一种在远程服务器上调用python脚本并轮询状态并获取输出的最佳方法。 It is preferable for me to have this implementation also in python. 对我来说,最好在python中也有此实现。 The python script takes a very long time to execute and I want to poll the status intermediately on what all actions are being performed. python脚本需要很长时间才能执行,我想在所有执行操作的中间轮询状态。 Any suggestions? 有什么建议么?

There are so many options. 有很多选择。 'Polling' is generally a bad idea, as it assumes CPU occupation. “轮询”通常是一个坏主意,因为它假定占用了CPU。

  • You could have your script send you status changes. 您可以让脚本向您发送状态更改。

  • You could have your script write it's actual status into a (remote) file (wither overwriting or appending to a log file) and you can look into that file. 您可以让脚本将其实际状态写入(远程)文件(无需覆盖或附加到日志文件中),然后可以查看该文件。 This is probably the easiest way. 这可能是最简单的方法。 You can monitor the file with tail -f file over the link 您可以在链接上使用tail -f file监视文件

  • And many more - and more complicated - other options. 还有更多(更复杂)的其他选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM