I found another way of doing this, thanks to this post that uses of tornado.gen.Return. I still need to yield in my main function, but the coroutine is simple.
Here is my code now:
#------ file views.py -------------
@web.asynchronous
@gen.coroutine
class Contact_handler(Main_handler):
def get(self, other_id):
event = events.Event_send_contact_request(self.user_id)
result = yield model.push_event_to_user(other_id, event)
self.finish("ok")
And the call in another function:
#------ file model.py -------------
@gen.coroutine
def push_event_to_user(user_id, event):
## Ajout de la demande dans les events du demandé:
result = yield motor.Op(db.users.update,
{'_id': ObjectId(user_id)},
{'$push': {'evts': event}}
)
raise gen.Return(result)