code: def write_remaining(self):
          
          if not self.results:
              return
          with db.execution_context():
              with db.atomic():
                  Result.insert_many(self.results).execute()
          del self.results[:]
docs: Write the remaning stack content