<commit_before># encoding: utf-8

task :sync => :environment do
  threads = []
  locked = false  

  pull_thread = Thread.new do
    while true do
      puts "‹Thread/Pull› Starting\n"
      locked = true
      begin
        Project.synchronizer.pull_collection
        Project.all.each do |project|
          # puts "‹Thread/Pull› Pulling project #{project.name}\n"
          Story.synchronizer.set_context :projects, project._remote_id
          Story.synchronizer.pull_collection
        end
      rescue
        puts "‹Thread/Pull› FAILED\n"
      end
      puts "‹Thread/Pull› Finished\n"
      locked = false
      sleep 60
    end
  end

  push_thread = Thread.new do
    while true do
      if locked
        puts "‹Thread/Push› Waiting for unlock\n"
      else
        puts "‹Thread/Push› Starting\n"

        @queue = Synchronizer::Queue.instance

        if @queue.should_run?
          puts "‹Thread/Push› Running queue\n"
          @queue.run<commit_msg>Added exception listing to sync task<commit_after># encoding: utf-8

task :sync => :environment do
  threads = []
  locked = false  

  pull_thread = Thread.new do
    while true do
      puts "‹Thread/Pull› Starting\n"
      locked = true
      begin
        Project.synchronizer.pull_collection
        Project.all.each do |project|
          # puts "‹Thread/Pull› Pulling project #{project.name}\n"
          Story.synchronizer.set_context :projects, project._remote_id
          Story.synchronizer.pull_collection
        end
      rescue Exception => e
        puts "‹Thread/Pull› FAILED\n"
        puts "---------------------"
        puts e.message
        puts e.backtrace.join('\n')
        puts "---------------------"
      end
      puts "‹Thread/Pull› Finished\n"
      locked = false
      sleep 60
    end
  end

  push_thread = Thread.new do
    while true do
      if locked
        puts "‹Thread/Push› Waiting for unlock\n"
      else
        puts "‹Thread/Push› Starting\n"

        @queue = Synchronizer::Queue.instance

        if @queue.should_run?
          puts "‹Thread/Push› Running queue\n"
          @queue.run
{'fraction_non_alphanumeric': 0.11211401425178147, 'fraction_numerical': 0.0028503562945368173, 'mean_word_length': 1.880984952120383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4968477', 'n_tokens_mistral': 631, 'n_tokens_neox': 657, 'n_words': 164}