Sha256: 0cb6c89c6e10b0074171f3d2eaa29483a5bb146c4fdfcbff1468f6bb2f929b94

Contents?: true

Size: 580 Bytes

Versions: 10

Compression:

Stored size: 580 Bytes

Contents

require 'open-uri'
require 'thread'

module Mixpanel
  class Tracker
    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
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mixpanel-2.2.0 lib/mixpanel/tracker/subprocess.rb
mixpanel-2.1.0 lib/mixpanel/tracker/subprocess.rb
mixpanel-2.0.2 lib/mixpanel/tracker/subprocess.rb
mixpanel-2.0.1 lib/mixpanel/tracker/subprocess.rb
mixpanel-2.0.0 lib/mixpanel/tracker/subprocess.rb
mixpanel-1.1.3 lib/mixpanel/tracker/subprocess.rb
mixpanel-1.1.2 lib/mixpanel/tracker/subprocess.rb
mixpanel-1.1.1 lib/mixpanel/tracker/subprocess.rb
mixpanel-1.0.0 lib/mixpanel/tracker/subprocess.rb
mixpanel-0.9.0 lib/mixpanel/tracker/subprocess.rb