@tornado.gen.coroutine
def get_next_id(db, collection):
    counter = (yield db.counters.find_and_modify({'_id': '{}id'.format(collection)}, {'$inc': {'seq': 1}}, new=True))
    raise tornado.gen.Return(counter['seq'])
@tornado.gen.coroutine
def get_next_id(db, collection):
    counter = (yield db.counters.find_and_modify({'_id': '{}id'.format(collection)}, {'$inc': {'seq': 1}}, new=True))
    raise tornado.gen.Return(counter['seq'])