简体   繁体   English

Python:如何从另一个进程读取变量?

[英]Python: how to read variables from another process?

So i'm building a custom machine learning simulation and wanting to read certain values from a training process, in another one to visualize real time training data. 因此,我正在构建一个自定义的机器学习模拟,并希望从训练过程中读取某些值,在另一个过程中以可视化方式显示实时训练数据。

So for example, the training simulation has an array of values under a data structure. 因此,例如,训练模拟在数据结构下具有一组值。 Let's say the data structure is an instantiated class called data . 假设数据结构是一个名为data的实例化类。 Inside this class, there is a list of values, let's call it values . 在此类内,有一个值列表,我们称其为values

This simulation has a training loop, so while that training loop is going, I would like to run another script that can query data.values and do something with it. 该模拟有一个训练循环,因此在进行该训练循环时,我想运行另一个可以查询data.values并对其进行处理的脚本。

Is this possible? 这可能吗? - Ideally I would like to keep my simulation code as is so as to not add necessary bulk. -理想情况下,我想保持仿真代码不变,以免增加必要的批量。

You can use a message queue for that. 您可以为此使用消息队列。 Add the value to the queue in your loop process and read and visualize with the other application. 将值添加到循环过程中的队列中,并使用其他应用程序进行读取和可视化。 Take a look at RabbitMQ 看看RabbitMQ

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

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