0
我目前正在使用Google应用引擎的内置分贝。看起来,当我运行put()
向数据库中插入一个元组时,即使该元组还没有被完全插入,该函数也会返回。下面的代码:Google App Engine数据库在返回之前不会执行完毕
new_user = Users(username=username_input, hashed_password=get_hashed_password(username_input, password))
new_user.put()
existing_user = None
while not existing_user:
print "existing_user still not in DB"
#tries to get the user that was put into the DB
existing_user = db.GqlQuery("SELECT * FROM Users WHERE username=:username_input", username_input=username_input).get()
print "existing_user in DB"
当我运行这段代码,我得到下面的输出,
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user in DB
为什么会出现这种情况? put()
不应该在返回之前将元组放入数据库吗?