从另一个MongoDB连接读取您自己的写操作

2024-03-28 18:33:17 发布

您现在位置:Python中文网/ 问答频道 /正文

假设我们有如下两个过程

# process 1

from pymongo import MongoClient

db = MongoClient().test

db.test.insert({'_id': test}, w=1)

send_data_ready()  # sending notification to another process
# process 2

from pymongo import MongoClient

db = MongoClient().test

def on_data_ready():
    # trying to read the document after notification received
    result = db.test.find_one({'_id': test})
    assert result

第一个进程执行一些写操作,然后通知第二个进程数据准备就绪。然后第二个进程开始读取修改后的数据。第二个进程总是读取新数据,对吗?MongoDB是作为一个独立服务器启动的(不是作为一个副本集)。 所有的写操作都是用已确认的写关注点({w:1})进行的。不同连接之间的一致性有什么保证吗?我在官方文件里没找到


Tags: to数据fromtestimportiddbdata