Hi, Following the article on sharded counter, I decided to extended it a bit to add a function that returns the current count and increments the counter.
Here's the function: def get_count_and_increment(name): config = GeneralCounterShardConfig.get_or_insert(name, name=name) def txn(): total = memcache.get(name) if total is None: total = 0 for i in range(1, config.num_shards): counter = GeneralCounterShard.get_by_key_name(name + str(i)) if counter is not None: total += counter.count memcache.add(name, str(total), 60) index = random.randint(0, config.num_shards - 1) shard_name = name + str(index) counter = GeneralCounterShard.get_by_key_name(shard_name) if counter is None: counter = GeneralCounterShard(key_name=shard_name, name=name) counter.count += 1 counter.put() memcache.incr(name) return total return db.run_in_transaction(txn) It works fine on the dev_server but on the production servers it throws the following error: BadRequestError: can't operate on multiple entity groups in a single transaction. Can anyone give me a pointer? Thanks -- Joe --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---