code: def handle_cursor(cls, cursor, query, session):
          
          from pyhive import hive  # pylint: disable=no-name-in-module
          unfinished_states = (
              hive.ttypes.TOperationState.INITIALIZED_STATE,
              hive.ttypes.TOperationState.RUNNING_STATE,
          )
          polled = cursor.poll()
          last_log_line = 0
          tracking_url = None
          job_id = None
          while polled.operationState in unfinished_states:
              query = session.query(type(query)).filter_by(id=query.id).one()
              if query.status == QueryStatus.STOPPED:
                  cursor.cancel()
                  break
  
              log = cursor.fetch_logs() or ''
              if log:
                  log_lines = log.splitlines()
                  progress = cls.progress(log_lines)
                  logging.info('Progress total: {}'.format(progress))
                  needs_commit = False
                  if progress > query.progress:
                      query.progress = progress
                      needs_commit = True
                  if not tracking_url:
                      tracking_url = cls.get_tracking_url(log_lines)
                      if tracking_url:
                          job_id = tracking_url.split('/')[-2]
                          logging.info(
                              'Found the tracking url: {}'.format(tracking_url))
                          tracking_url = tracking_url_trans(tracking_url)
                          logging.info(
                              'Transformation applied: {}'.format(tracking_url))
                          query.tracking_url = tracking_url
                          logging.info('Job id: {}'.format(job_id))
                          needs_commit = True
                  if job_id and len(log_lines) > last_log_line:
                      # Wait for job id before logging things out
                      # this allows for prefixing all log lines and becoming
                      # searchable in something like Kibana
                      for l in log_lines[last_log_line:]:
                          logging.info('[{}] {}'.format(job_id, l))
                      last_log_line = len(log_lines)
                  if needs_commit:
                      session.commit()
              time.sleep(hive_poll_interval)
              polled = cursor.poll()
docs: Updates progress information