tweetstream / em-twitter

Twitter Streaming API client for EventMachine
http://rubygems.org/gems/em-twitter
MIT License
42 stars 16 forks source link

Will it lose data potentially? #20

Closed steventen closed 9 years ago

steventen commented 9 years ago

Hi,

I'm using em-twitter to track the /1.1/statuses/filter.json api.

An example code that includes a periodic timer would like below :

EM.run do
    client = EM::Twitter::Client.connect(options)
    client.each do |status|
        # handle_tweet ...
    end
    EM.add_periodic_timer(5) do
        # other job
    end
end

So the question is, since every 5 seconds event loop will jump to other job (e.g. an async connection to database), will this potentially lose some streaming data we are tracking at this point of time?

Thanks

stve commented 9 years ago

I would advise not blocking the event loop inside your timer. But theoretically, no, I don't think this would prevent data from being received. I believe your data would be handled in the next tick.