code: def wait(self, poll_interval=1, timeout=None, full_data=False):
          
  
          end_time = None
          if timeout:
              end_time = time.time() + timeout
  
          while end_time is None or time.time() < end_time:
  
              job_data = self.collection.find_one({
                  "_id": ObjectId(self.id),
                  "status": {"$nin": ["started", "queued"]}
              }, projection=({
                  "_id": 0,
                  "result": 1,
                  "status": 1
              } if not full_data else None))
  
              if job_data:
                  return job_data
  
              time.sleep(poll_interval)
          raise Exception("Waited for job result for %s seconds, timeout." % timeout)
docs: Wait for this job to finish.