Sha256: ac54ff978639afc5861b09a63bcb863205b303240e9635b2dd8d6c9c9ed3853c

Contents?: true

Size: 518 Bytes

Versions: 15

Compression:

Stored size: 518 Bytes

Contents

require 'open-uri'
require 'thread'

module Mixpanel
  class Subprocess
    Q = Queue.new
    ENDMARKER = Object.new

    Thread.abort_on_exception = true
    producer = Thread.new do 
      STDIN.each_line() do |url|
        STDERR.puts("Dropped: #{url}") && next if Q.length > 10000
        Q << url
      end
      Q << ENDMARKER
    end

    loop do
      url = Q.pop
      break if(url == ENDMARKER)
      url.chomp!
      next if(url.empty?) #for testing
      open(url).read
    end
    producer.join
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mixpanel-4.0.6 lib/mixpanel/subprocess.rb
mixpanel-4.0.5 lib/mixpanel/subprocess.rb
mixpanel-4.0.4 lib/mixpanel/subprocess.rb
mixpanel-4.0.3 lib/mixpanel/subprocess.rb
mixpanel-4.0.2 lib/mixpanel/subprocess.rb
mixpanel-4.0.1 lib/mixpanel/subprocess.rb
mixpanel-4.0.0 lib/mixpanel/subprocess.rb
mixpanel-3.6.2 lib/mixpanel/subprocess.rb
mixpanel-3.5.2 lib/mixpanel/subprocess.rb
mixpanel-3.5.1 lib/mixpanel/subprocess.rb
mixpanel-3.5.0 lib/mixpanel/subprocess.rb
mixpanel-3.4.0 lib/mixpanel/subprocess.rb
mixpanel-3.1.0 lib/mixpanel/subprocess.rb
mixpanel-3.0.2 lib/mixpanel/subprocess.rb
mixpanel-3.0.1 lib/mixpanel/subprocess.rb