python - Concurent Access to datastore in app engine -


i want know if db.run_in_transaction() acts lock data store operations , helps in case of concurrent access on same entity.

does in following code guarantied concurrent access not cause race , instead of creating new entity not over-write

is db.run_in_transaction() correct/best way so

in following code m trying create new unique entity following code

def txn(charmer=none):     new = none     key = my_magic() + random_part()     sk = snake.get_by_name(key)     if not sk:        new = snake(key_name=key, charmer= charmer)        new.put()     return new db.run_in_transaction(txn, charmer)  

that safe method. should same name generated twice, 1 entity created.

it sounds have looked @ transactions documentation. there more detailed description.

check out docs (specifically equivalent code) on model.get_or_insert, answers question asking:

the , subsequent (possible) put wrapped in transaction ensure atomicity. ths means get_or_insert() never overwrite existing entity, , insert new entity if , if no entity given kind , name exists.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -