与另一个要更新第一个进程的进程一起连续运行进程的最佳方法

问题描述 投票:0回答:1

您好,我是用python编写实时事物的新手。只是想知道如何通过不同的功能(从用户输入中读取数据)更新bpm时,如何最好地解决以给定bpm进行恒定拍的问题。

    def gatherAndProcessData():
      return newBPM

    def playBeat(newBPM):
      subprocess.call(["python.exe", "playBeat.py"])  # Calling the Beat

    def main():
       while True:
            with concurrent.futures.ThreadPoolExecutor() as executor:
                 executor.submit(gatherData, (event_time,))
                 executor.submit(playBeat, (oscillator_machine.freq,))

这是目前运行的代码的更基本版本,我认为已经足够,但是如果有更多详细信息有帮助,请告诉我,我会添加更多内容。

我目前正在尝试线程池,但是不确定它们如何工作。我认为上面的代码可能接近解决方案,但目前无法正常工作。我期望从collectData返回bpm的返回值,该值也会在该函数的末尾打印,但是print语句不会打印,并且executor.submit返回一个将来的集合,所以我不确定如何从函数中访问返回的值该集。

任何帮助将不胜感激。再次感谢

python python-asyncio thread-synchronization
1个回答
0
投票

嗨,@ Darragh Lynch,欢迎您来Stack!

最近,我发现了Airflow项目,可以自动执行任务并并行运行我的流程。我真的建议您看一下,男子气概,因为它非常容易设置和管理您的日志:

https://airflow.apache.org/docs/stable/start.html

© www.soinside.com 2019 - 2024. All rights reserved.