简体   繁体   English

Python 脚本间通信的建议

[英]Recommendations for communication between Python scripts

I want to write a few python3 scripts that can retrieve almost instantly some variables (less than 400 integers in total) shared by one another.我想编写一些 python3 脚本,它们几乎可以立即检索一些彼此共享的变量(总共少于 400 个整数)。

  • One script shares specific variable.一个脚本共享特定的变量。 Many scripts can read this variable.许多脚本可以读取这个变量。
  • Script can update value up to 50 times per second and share up to 50 variables.脚本每秒最多可更新值 50 次并共享多达 50 个变量。
  • Bus should allow at least 10k R/W operations per second.总线应该允许每秒至少 10k R/W 操作。
  • Bus can be managed by master process总线可以由主进程管理
  • Hardware: ARM based board with modern Debian OS and 1GiB of RAM.硬件:基于 ARM 的主板,带有现代 Debian 操作系统和 1GiB 的 RAM。
  • KISS and lightweight KISS和轻量级

Some scripts are reading data from sensors and sharing their values.一些脚本从传感器读取数据并共享它们的值。 Some are logging values, other is processing data and sets its variables according to target motor speed.一些是记录值,另一些是处理数据并根据目标电机速度设置其变量。

I recommend one of the following solutions:我推荐以下解决方案之一:

  • shared memory (have a look at python multiprocessing values/arrays)共享内存(看看 python 多处理值/数组)
  • an HTTP server via TCP/IP or a local os socket通过 TCP/IP 或本地操作系统套接字的 HTTP 服务器

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

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