gpt4 book ai didi

python - 在两个 Python 程序之间共享一个 LIFO 结构

转载 作者:行者123 更新时间:2023-11-28 19:26:00 28 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Clean way to get near-LIFO behavior from multiprocessing.Queue? (or even just *not* near-FIFO)

我想在两个不同的 Python 程序之间共享一个 LIFO (Queue.LifoQueue()) 结构。

一个将作为作者,另一个将作为读者

目前它只是一个共享读/写时间的简单应用程序。

读者应在 LIFO 上插入 UNIX 时间戳,并让读者阅读它:

**#writer.py**
def getWriteTime():
os.system("date +%s")
# write to the LIFO structure



**#reader.py**
def getReadTime():
# read from the LIFO structure
# do calculations

问题是,我如何在两个 python 程序之间共享相同的数据结构而不将其写入磁盘?

我知道 multiprocessing 库允许在进程之间共享资源,但我不太明白如何在 python 程序之间共享 LIFO(队列)

提前致谢

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com