我目前正在使用 django non-rel Web 框架开发一个谷歌应用程序引擎应用程序。我有一种方法可以将钱从一个帐户转移到另一个帐户,非常简单。当我使用调试器在本地服务器上运行它时,它工作正常并正确转移所有资金。然而,当我在应用程序引擎上远程运行它时,我最终得到了奇怪的负值。该方法的关键在于:
pubAccount.secondary_money = pubAccount.secondary_money + transaction.money
pubAccount.money = pubAccount.money - transaction.money
经过广泛的研究,我发现这可能是由于我没有使用事务,这意味着传输绝不是原子的,因此可能会发生竞争条件。但是 django non-rel 不能正确支持事务,并且它所支持的部分不受应用程序引擎直接支持,并且根据我的发现,python-app 引擎工具包支持的任何内容都不被 django non-rel 支持.
谁能告诉我如何使用 django non-rel 在应用程序引擎上进行交易!? 一定有人在那里解决了这个问题!
最佳答案
编辑:
如果有帮助,这是我使用的分支,运行 django-1.4,并支持祖先查询。
https://github.com/dragonx/djangoappengine.git -> django-1.4 branch
https://github.com/dragonx/django-1.4.git -> 1.4-nonrel branch
https://github.com/dragonx/djangotoolbox.git -> features/django-1.4 branch
https://github.com/dragonx/django-dbindexer.git -> develop branch (although the 1.4wip branch looks better)
关于python - App Engine Django 非相关竞争条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13423053/