I have a piece of code like below which is truncated for concise: bargained_count = BargainLog.objects.filter(bargain_start_log=bargain_start_log).count() ... money = calc_single_bargain_money( bargained_count=bargained_count, ...... ) ... BargainLog.objects.create(bargain_start_log=bargain_start_log, money=money, ...)
bargained_count is a parameter of func calc_single_bargain_money. But, because of the race condition, I am not sure if this is one kind of race condition. I may get bargained_count as same values in high concurrency which will affect the result of calc_single_bargaiN_money. So, how should I avoid it, please give me some advice. Like in multi threading, I want to add a lock before getting bargained_count and release the lock after creating new BargainLog instance to ensure they are bundled together. -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/bfe8d93f-4e51-45e7-b8f7-b38c39767941n%40googlegroups.com.