Duplicate key error index Appeared When Mongo insert

  mongodb, question

My mongo table does not have any indexes built by myself, only a _id index built by mongo

There is a cycle when inserting, the first insert is successful, and the second insert will report an error.

pymongo.errors.DuplicateKeyError: E11000 duplicate key error index: ed.uq.$_id_  dup key: { : ObjectId('539524645b8fcf3b3d6c4796') }

My code is like this

while begin < end:
 begin += 1

Mongo’s version number is 2.4.3
Is this mongo bug?
How should this situation be resolved?

MongoDB’s _id cannot be duplicated, this is a unique index that comes with it.