<commit_before>'use strict';
var processors = require('../processors'),
    _ = require('underscore'),
    replify = require('replify'),
    undefsafe = require('undefsafe'),
    binModel = require('../models').createModels().bin;

var utils = {},
    sessions = {},
    sessionsFromUser = {},
    pending = {},
    pendingToKillStreaming = {};

var metrics = require('../metrics'),
    openSpikes = 0;

setInterval(function () {
  pending = {};
}, 15 * 60 * 1000);

replify('spike', {
  utils: utils,
  sessions: sessions,
  sessionsFromUser: sessionsFromUser,
  pending: function () {
    return pending;
  },
  openSpikes: function () {
    return openSpikes;
  }
});

// keep checking the sessions we have, and if any of the response objects
// are no longer writable, then we removed them from our list
setInterval(function () {
  Object.keys(sessions).forEach(function (id) {
    sessions[id].res.forEach(function (res) {
      if (!res.connection.writable) {
        utils.removeConnection(id, res);
      }
    });
  });
}, 1000 * 60);


/**<commit_msg>Check for absence of res.connection<commit_after>'use strict';
var processors = require('../processors'),
    _ = require('underscore'),
    replify = require('replify'),
    undefsafe = require('undefsafe'),
    binModel = require('../models').createModels().bin;

var utils = {},
    sessions = {},
    sessionsFromUser = {},
    pending = {},
    pendingToKillStreaming = {};

var metrics = require('../metrics'),
    openSpikes = 0;

setInterval(function () {
  pending = {};
}, 15 * 60 * 1000);

replify('spike', {
  utils: utils,
  sessions: sessions,
  sessionsFromUser: sessionsFromUser,
  pending: function () {
    return pending;
  },
  openSpikes: function () {
    return openSpikes;
  }
});

// keep checking the sessions we have, and if any of the response objects
// are no longer writable, then we removed them from our list
setInterval(function () {
  Object.keys(sessions).forEach(function (id) {
    sessions[id].res.forEach(function (res) {
      if (!res.connection || !res.connection.writable) {
        utils.removeConnection(id, res);
      }
    });
  });
}, 1000 * 60);


/**
{'fraction_non_alphanumeric': 0.15950069348127602, 'fraction_numerical': 0.013869625520110958, 'mean_word_length': 3.3366733466933867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7347036', 'n_tokens_mistral': 684, 'n_tokens_neox': 653, 'n_words': 161}