Feeds Importer running multiple times My feeds importer is acting very strange and running the same import multiple times..

This is what my importer looks like:

class FeedsASUNewCareer extends FeedsCSVParser {
  /**
   * Implements FeedsParser::parse().
   */
  public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
    global $user;
    $source_config = $source-&gt;getConfigFor($this);
    $state = $source-&gt;state(FEEDS_PARSE);

    // Load and configure parser.
    feeds_include_library('ParserCSV.inc', 'ParserCSV');
    $parser = new ParserCSV();
    $delimiter = $source_config['delimiter'] == 'TAB' ? "\t" : $source_config['delimiter'];
    $parser-&gt;setDelimiter($delimiter);

    $iterator = new ParserCSVIterator($fetcher_result-&gt;getFilePath());
    if (empty($source_config['no_headers'])) {
      // Get first line and use it for column names, convert them to lower case.
      $header = $this-&gt;parseHeader($parser, $iterator);
      if (!$header) {
        watchdog('CAREER IMPORT ERROR', "Could not parse header");
        return;
      }
      $parser-&gt;setColumnNames($header);
    }

    // Determine section to parse, parse.
    $start = $state-&gt;pointer ? $state-&gt;pointer : $parser-&gt;lastLinePos();
    $limit = $source-&gt;importer-&gt;getLimit();
    $rows = $this-&gt;parseItems($parser, $iterator, $start, $limit);

    // Report progress.
    $state-&gt;total = filesize($fetcher_result-&gt;getFilePath());
    $state-&gt;pointer = $parser-&gt;lastLinePos();
    $progress = $parser-&gt;lastLinePos() ? $parser-&gt;lastLinePos() : $state-&gt;total;
    $state-&gt;progress($state-&gt;total, $progress);

    $careers = array();

    watchdog('careers', '&lt;pre&gt;' . print_r($rows, TRUE) . '&lt;/pre&gt;');
    foreach($rows as $career) {
        // create career.
        $node = entity_create('node', array('type' =&gt; 'careers'));
        $entity = entity_metadata_wrapper('node',$node);
        // Set Entity properties
        $entity-&gt;title-&gt;set($career['alternate_title']);
        $entity-&gt;language = 'en';
        $entity-&gt;author = $user-&gt;uid;
        $entity-&gt;status = $career['status'];
        $entity-&gt;body-&gt;set(array('value' =&gt; $career['body']));
        $entity-&gt;field_alternate_title-&gt;set($career['alternate_title']);
        $entity-&gt;field_career_category_image-&gt;set($career['car_category_img']);
        $entity-&gt;field_careercategory-&gt;set($setCategoryId);

        // Save Career
        $entity-&gt;save(); //Save new Entity wrapper
        $node-&gt;tnid = $node-&gt;nid;
        $entity-&gt;save();
      }
    }

    // return empty set.
    $ret = new FeedsParserResult();
    return $ret;
  }
}



When I go to Content &gt; Import and select this Feed Importer to use, it just gets hung up on the processing page and in my logs I can see my watchdog watchdog('careers', '&lt;pre&gt;' . print_r($rows, TRUE) . '&lt;/pre&gt;'); executes over and over until I stop it. Keep in mind that watchdog is not in a loop, so the feeds importer is just running endlessly until I stop it.

What could cause the importer to act with such behavior?
It could be that there's a bug in the parser's reporting progress. As long as the parser doesn't tell Feeds parsing is done, Feeds will keep calling the parser over and over again.

Workflow of Feeds


Fetch data.
Parse 50 first items of data.
Process 50 items.
Feeds checks if the parser's progress is complete. If not, the next 50 items of data are parsed.
Process 50 items.


When there's nothing more to parse, Feeds checks if there's more to fetch. If so, above steps are repeated. If not, import finishes.