[patch] get or create thread safety
|Reported by:||toplex||Owned by:||toplex|
|Component:||Database layer (models, ORM)||Version:||1.1|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If you try get_or_create from several threads at the same time, you'll get duplicates sooner or later. Same goes for adding relations (which checks for duplicates on it's own).
This is a small patch to fix it using a Lock mechanism.
Obviously it won't work when tried from several processes, so I would call it an intermediate patch.
This is my first time touching Django code, so I'm sorry for any screw ups.