Search code examples
pythonpython-3.xmongodbpymongopymongo-3.x

How to wait until data is inserted into a mongodb timeseries collection?


I am using Python 3.9 and MongoDB 5.0.6.

I have a function that has insert_many call inside. I want to wait until the data is inserted into the timeseries collection before return. How can I do that?


Solution

  • By default pymongo is synchronous, so the insert_many() function call will not return until the data is inserted, so there's no specific need to wait.

    This assumes you're not using the motor async driver or trying to read from a secondary replica.