简体   繁体   English

获取正在运行的Python程序的实例

[英]Get instance of an running Python program

Suppose a python program is running. 假设正在运行python程序。 Say the object of an Class in that program can give you some stats. 说该程序中的Class对象可以提供一些统计信息。 So if i have to develop a web UI to display the stats, how do i get the instance of that class which is running[as an separate desktop app] and display the stats in web, which I would be using web2py or django. 因此,如果我必须开发一个Web UI来显示统计信息,我该如何获取正在运行的类的实例(作为单独的桌面应用程序)并在Web中显示统计信息,而我将使用web2py或django。

You can't (easily) "get an instance of a running program" from outside. 您不能(轻松)从外部“获取正在运行的程序的实例”。 You can certainly instrument your program so that it communicates its statistics somehow, eg via a socket, or as an even lower-tech solution you could get it to store the relevant data periodically in a file on disk or in a database, which your web app could read. 您当然可以对您的程序进行检测,以便它以某种方式传达其统计信息,例如通过套接字,或者作为一种较低技术的解决方案,您可以让它定期将相关数据存储在磁盘或数据库中的文件中,而网络应用可以读取。

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

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