Here's what I'm suggesting with `enumerate`:

    for num, doc in enumerate(docs_to_dump()):
        if num % 10000 == 0:
            logging.debug("Upserted %d docs." % num)
            dm.upsert(self.filter_fields(doc))
    logging.debug("Upserted %d  docs" % num)

The advantage here lies in not having to initialize and maintain your own counter `num` manually.