<commit_before># encoding: UTF-8
require 'spec_helper'
require 'mysql2/em'

describe Mysql2::EM::Client do
  it "should support async queries" do
    results = []
    EM.run do
      client1 = Mysql2::EM::Client.new
      defer1 = client1.query "SELECT sleep(0.05) as first_query"
      defer1.callback do |result|
        results << result.first
        EM.stop_event_loop
      end

      client2 = Mysql2::EM::Client.new
      defer2 = client2.query "SELECT sleep(0.025) second_query"
      defer2.callback do |result|
        results << result.first
      end
    end
    
    results[0].keys.should include("second_query")<commit_msg>make sure we don't hit a race condition if this EM spec is taking longer to run than normal<commit_after># encoding: UTF-8
require 'spec_helper'
require 'mysql2/em'

describe Mysql2::EM::Client do
  it "should support async queries" do
    results = []
    EM.run do
      client1 = Mysql2::EM::Client.new
      defer1 = client1.query "SELECT sleep(0.1) as first_query"
      defer1.callback do |result|
        results << result.first
        EM.stop_event_loop
      end

      client2 = Mysql2::EM::Client.new
      defer2 = client2.query "SELECT sleep(0.025) second_query"
      defer2.callback do |result|
        results << result.first
      end
    end
    
    results[0].keys.should include("second_query")
{'fraction_non_alphanumeric': 0.1011070110701107, 'fraction_numerical': 0.03025830258302583, 'mean_word_length': 2.777158774373259, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1503338', 'n_tokens_mistral': 448, 'n_tokens_neox': 421, 'n_words': 117}