how to lock a mongodb object between celery worker and web service

my web service will start a celery worker async, in this worker objectA (mongodb document) could be updated, how should I lock the object when a request come to update objectA? there are 2 process , one is web service ,the other is celery worker