Is get_or_create() thread safe

后端 未结 4 1820
一向
一向 2020-12-24 11:46

I have a Django model that can only be accessed using get_or_create(session=session), where session is a foreign key to another Django model.

Since I am

4条回答
  •  死守一世寂寞
    2020-12-24 12:26

    Threading is one problem, but get_or_create is broken for any serious usage in default isolation level of MySQL:

    • How do I deal with this race condition in django?
    • Why doesn't this loop display an updated object count every five seconds?
    • https://code.djangoproject.com/ticket/13906
    • http://www.no-ack.org/2010/07/mysql-transactions-and-django.html

提交回复
热议问题