[pymongo] pymongo.errors.CursorNotFound Exception

Because after the find, loop execution time is too long cause timeout, cusor failure

There are several solutions:

1. Use the batch_size ()

    cursor = collection.find({}).batch_size(30)

2. Remove the cursor into the list

    result = list(collection.find({}))

3. cancel timeout limit, to close after using the cursor

    cursor = collection.find({}, no_cursor_timeout=True)

    cursor.close() 

# Finally a way that still appear in the use of exception, the reason is not clear, know a friend please let me know.

Guess you like

Origin www.cnblogs.com/sipher/p/11406898.html